MongoDB: execute mapreduce and filter using java driver 3.0.x

I work in a small java and mongoDB project with java driver 3.0.1. It is necessary to execute the MapReduce algorithm and prior to the map function, execute one query in order to have less data and increase productivity.

I saw the api driver and there was a MongoCollection class with the mapReduce method , but only with the map and reduce function as a parameter. it has no query parameter.

dbConnection.getCollection("test").mapReduce(mapFunction, reduceFunction)

The old API has a MapReduceCommand for this

MapReduceCommand cmd = new MapReduceCommand("test", map, reduce, null, MapReduceCommand.OutputType.INLINE, query)

Any suggestions?

Thanks everyone!

+4
source share
1 answer

mapReduce MongoCollection MapReduceIterable, filter , . :

dbConnection.getCollection("test").mapReduce(mapFunction, reduceFunction)
                                  .filter(queryFilter)
+8

Source: https://habr.com/ru/post/1589449/


All Articles