java - MapReduce returns NaN -


i have m/r function, , nan value of results. dont have experience js. im escaping js using java drivers.

string map = "function(){" + " emit({"             + "country: this.info.location.country, "             + "industry: this.info.industry}, {count : 1});  }";  string reduce = "function(key, values){var count = 0.0;"             + "values.foreach(function(v){ count += v['count'];});"             + "return count;}"; mapreduceoutput output = collection.mapreduce(map, reduce, null,             new basicdbobject("lid", "foo")); 

an example ti clear things:

{"_id":{"country":"gb", "industry":"foo"}, "value":nan} 

thanks lot.

considering js part, i'm not sure whether following part valid -

values.foreach(function(v){ count += v['count'];}); 

try instead -

var v; (v in values) {     .... } 

hope helps!


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -