+ "function(category){emit(category, {count:1});}" + ");"
+ "};";
String reduce = "function(key, values){" + "var sum = 0;"
+ "for(var i=0;i<values.length;i++)"
+ "sum += values[i].count;" + "return {count: sum};" + "};";
MapReduceOutput output = collection.mapReduce(map, reduce, null,
MapReduceCommand.OutputType.INLINE, null);
List<DBObject> result = Lists.newArrayList(output.results());
Collections.sort(result, bookComparator);
assertThat((String) result.get(0).get("_id"), equalTo("crime"));
DBObject count1 = (DBObject) result.get(0).get("value");
assertThat((Double) count1.get("count"), equalTo(1.0D));