Mongodb Mongo-获取lastnames的出现率

Mongodb Mongo-获取lastnames的出现率,mongodb,Mongodb,我想知道收藏中姓氏的出现情况。我正在使用以下命令: m = function() { this.lastname.forEach( function(z) { emit( z , { count : 1 } ); }); }; r = function(p, c) { var total = 0; for (var i =0; i < c.length; i++) total += c[i].count; return { count : total }; }; res = db.pro

我想知道收藏中姓氏的出现情况。我正在使用以下命令:

m = function() { this.lastname.forEach( function(z) { emit( z , { count : 1 } ); }); };
r = function(p, c) { var total = 0; for (var i =0; i < c.length; i++) total += c[i].count; return { count : total }; };

res = db.properties.mapReduce(m,r);
m=function(){this.lastname.forEach(函数(z){emit(z,{count:1});});};
r=函数(p,c){vartotal=0;for(vari=0;i
我得到以下错误:

未捕获异常:断言失败: 需要输入选项或输出字符串


有什么想法吗?

如果您使用的是>v1.7.4,则需要指定输出选项:

e、 g


这将结果存储到命名集合中。请参见此处文档的“输出选项”部分:

@Tomasz:Oops,我不知道这一点。谢谢你的提醒。
res = db.properties.mapReduce(m,r, {out: "CollectionToOutputResultsTo"});