rmarut Posted May 15, 2012 Share Posted May 15, 2012 Hi,I have MongoDB shell 2.1.1I have a Collection with elements Things, Value, List: where List is an N+ Array of Strings, i.e. "Things" : "Function", "Value" : "Element", "List" : ["loc1", "loc2","loc3] simple to sum List by key: Things, Value on mongodb shell:db.report.find().forEach( function(feature) { print(feature.feature + " " + feature.value + " " + feature.processes.length); }); returns: { "result" : [{ "_id" : { "Things" : "Function", "value" : "Element" }, "List" : 3}, ], "ok" : 1 } I have not been able to execute this from ireports.This is the MapReduce function I am executing:{ 'collectionName' : 'report', }, 'mapReduce' : { 'map' : 'function () { emit ({thing:this.Things,val:this.Value}, {count : this.List}); }', 'reduce' : 'function (key, values) { var total = 0; for (index i = 0; i < values.length; i++){ total += values[i}.List;; } return {total : values[i}.List;} }', 'out' : 'totalList' }} returns:_id.Things_____id.Value_____List Function_________Element___loc1,loc2,loc3 Please tell me how I can return a count of List and not the values of List. Can anyone assist?? Post Edited by rmarut at 05/17/2012 18:35 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now