Just a note to record the usage of Map-Reduce with MongoDB and Morphia. Firstly, add the Morphia dependency.
<dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>2.11.2</version> </dependency> <dependency> <groupId>org.mongodb.morphia</groupId> <artifactId>morphia</artifactId> <version>0.105</version> </dependency> The syntax of MapReduceCommand in Morphia as shown in MapReduceCommand.java:
public MapReduceCommand( DBCollection inputCollection, String map, String reduce, String outputCollection, OutputType type, DBObject query) { // Compiled Code } Here we want to group the sales amount (i.e., subtotal) of each county and exclude the null-subtotal from collection. ...