NoSql-MapReduce

定义map:

var map=function(){for(var key in this){emit(key,{count:1})}}

定义Reduce:

var reduce=function(key,emits){total=0;for(var i in emits){total+=emits[i].count}return{"count":total}}

执行:

db.runCommand({"mapreduce":"liyiz","map":map,"reduce":reduce,"out":"mr"})