trying to group by date and number
my document
{ "_id" : ObjectId("4f956dee76ddb26752026e8f"), "request" : "default", "options" : "1", "keyword" : "somekey", "number" : "5b234b79-4d70-437e-8eef-32a2941af40a", "date" : "20120423200446", "time" : 1335193066 }
my query
map = "function() { var date = new Date(this.time * 1000); var key = date.getFullYear() + date.getMonth() + date.getDate(); emit({day : key, number: this.number}, {count: 1}); }"
reduce = "function(key, values) { var count = 0; values.forEach(function(v) { count += v['count']; }); return {count: count}; }"
db.txtweb.mapReduce(map, reduce, {out: "pageview_results"});
my error
uncaught exception: map reduce failed:{ "errmsg" : "ns doesn't exist", "ok" : 0 }
I cannot figure out whats wrong, but I think it is do something with the date functionality.
Any ideas.
ns doesn't existmeans that you’re accessing a non-existent database or collection. Check their namesScript below group this.amount by day (without time)