I'm working in a java small project and mongoDB with java driver 3.0.1. Need perform a MapReduce algorithm and before map function, execute one query to have less data and increment the performance.
I've seen api driver and exist the class MongoCollection with method mapReduce but only with map and reduce function as parameter. it doesn't have any query param.
dbConnection.getCollection("test").mapReduce(mapFunction, reduceFunction)
In old API, has MapReduceCommand for do this
MapReduceCommand cmd = new MapReduceCommand("test", map, reduce, null, MapReduceCommand.OutputType.INLINE, query)
Any suggestions?
Thanks all!
The mapReduce method on MongoCollection returns an instance of a MapReduceIterable, which has a filter method for the query filter to apply to the collection before executing the map phase. It looks like this:
dbConnection.getCollection("test").mapReduce(mapFunction, reduceFunction)
.filter(queryFilter)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With