示例文档:
{
"_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);
}
});
减少功能:
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
?