mapreduce « mongodb « Java Database Q&A

1. MongoDB MapReduce is much slower than pure Java processing?

I wanted to count all key's of my documents (inclusive embedded ones) of a collection. First I wrote a Java client to solve this. It took less than 4 seconds to ...

2. how to compute the average with mongodb and NumberLong

I am trying to compute an average value from a collection using the mongodb java driver, like this:

DBObject condition = new BasicDBObject("pluginIdentifier", plugin.getIdentifier());
DBObject initial = new BasicDBObject();
initial.put("count", 0);
initial.put("totalDuration", 0);
String reduce = ...

3. How do I pass parameters to Mongodb map/reduce in Java?

I have some data like this:

{id: 1, text: "This is a sentence about dogs", indices: ["sentence", "dogs"]}
{id: 2, text: "This sentence is about cats and dogs", indices: ["sentence", "cats", "dogs"]}
Where I ...

4. MongoDB's MapReduce function in Java returns null

I've some test data in my MongoDB:

> db.test2.find()
{ "_id" : ObjectId("4e76ad8e9d7dc2438ab63dbb"), "name" : "John", "number" : 2 }
{ "_id" : ObjectId("4e76ad8e9d7dc2438ab63dbc"), "name" : "Jane", "number" : 1 }
{ "_id" : ObjectId("4e76ad8e9d7dc2438ab63dbd"), ...