0
樣品DOC:的MongoDB - MapReduce的(......)不工作
{
"_id" : ObjectId("51cd7274267d959cb9f95cea"),
"creation_time" : 100,
"delivered" : true,
"id" : 1,
"user_id" : 10
}
地圖功能:
db.system.js.save({
_id: "mapDummy",
value: function(){
emit(this.user_id,this.user_id);
}
});
Reduce函數:
db.system.js.save({
_id: "reduceDummy",
value: function(key,values){
return Array.sum(values);
}
});
的MapReduce(...)函數調用:
db.newsdb.mapReduce("mapDummy", "reduceDummy", {out: "notifications_result", query: {delivered:true}});
{
"result" : "notifications_result",
"timeMillis" : 16,
"counts" : {
"input" : 12,
"emit" : 0,
"reduce" : 0,
"output" : 0
},
"ok" : 1,
}
爲什麼emit:0
?
+1是的,那就是問題所在。這個mapReduce示例只是爲了試試我的手。其實我想執行一些複雜的聚合任務,這是通過A/F無法實現的 –