My sample Json object is as follows
{
"numRecommenders": 0,
"publicProfileUrl": "http://www.linkedin.com/pub/heena-vyas/16/786/826",
"positions": {
"total": 1,
"positionList": [
{
"id": "91286566",
"title": "senior executive",
"company": {
"name": "Reliance",
"industry": "Oil & Energy",
"type": "Public Company",
"size": "10,001+ employees"
},
"isCurrent": true
}
]
},
My mapreduce function is give below:
String map = "function() {"
+"for (index in this.positions.positionList) {"
+"emit(this.positions.positionList[index].company.name, {count: 1});"
+"}}";
String reduce = "function(key, values) {" + "var sum = 0;"
+ "values.forEach(function(value) {" + "sum += value['count'];"
+ "});" + "return {count: sum};" + "};";
MapReduceCommand mapReduceCommand = new MapReduceCommand(
mongoCollection, map, reduce.toString(), null,
MapReduceCommand.OutputType.INLINE, null);
MapReduceOutput out = mongoCollection.mapReduce(mapReduceCommand);
But current I'm working with 1.5 million objects from mongoDb.
I'm getting the following exception..
Exception in thread "main" com.mongodb.CommandResult$CommandFailure: command failed [command failed [mapreduce] { "assertion" : "too much data for in memory map/reduce" , "assertionCode" : 13604 , "errmsg" : "db assertion failure" , "ok" : 0.0} at com.mongodb.CommandResult.getException(CommandResult.java:70) at com.mongodb.CommandResult.throwOnError(CommandResult.java:116) at com.mongodb.DBCollection.mapReduce(DBCollection.java:961) at com.mongo.dboperations.MongoStorage.runGroupCommand(MongoStorage.java:126)
at com.mongo.dboperations.MongoStorage.main(MongoStorage.java:218)
How to resolve this exception?