{
_id: 123
cust_id: "abc123",
ord_date: new Date("Oct 04, 2012"),
status: 'A',
price: 25,
}
Cust_id =>Key
Price =>value
_Id => Provenance Parameter
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/7663c675-fd61-43a7-9a34-49559af49913%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sir,
what i want in the result collection is{_id:cust_id,
value: {total: sum(price), id:[array of id's corresponding documents]}
}
As you said, i have written my Map function asvar mapFunction1 = function() {
emit(this.cust_id, {price:this.price, _id: [ this._id ]})
};
var reduceFunction1 = function(keyCustId, value) {
return {total:Array.sum(value['price']), id:Array([value['_id']])};
};
db.order.mapReduce( mapFunction1,reduceFunction1,{ out: "map_reduce_example" });
But its showing an error like
Error: map reduce failed:{
"errmsg" : "exception: TypeError: Cannot read property 'length' of undefined\n at Function.Array.sum (src/mongo/shell/types.js:192:12)\n at _funcs2 (_funcs2:3:47) at src/mongo/shell/types.js:192",
"code" : 16722,
"ok" : 0
}
at Error (<anonymous>)
at DBCollection.mapReduce (src/mongo/shell/collection.js:1227:15)
at (shell):1:10 at src/mongo/shell/collection.js:1227
Whats wrong with the program??
thankyou....
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/9e567afb-f287-42fc-882c-9e113444d41a%40googlegroups.com.