我正在尝试执行地图缩减直接进入Mongo以获取顶级标签,但我收到此错误,我不确定它意味着什么以及它有什么用。有什么指导吗?
> reduce= function(previous, current) {
... var count = 0;
...
... for (index in current) {
... count += current[index];
... }
...
... return count;
... }
function (previous, current) {
var count = 0;
for (index in current) {
count += current[index];
}
return count;
}
> reduce
function (previous, current) {
var count = 0;
for (index in current) {
count += current[index];
}
return count;
}
> map = function() {
... if (!this.stores) {
... return;
... }
... for (index in this.stores) {
... emit(this.stores[index], 1);
... }
... }
function () {
if (!this.stores) {
return;
}
for (index in this.stores) {
emit(this.stores[index], 1);
}
}
> map
function () {
if (!this.stores) {
return;
}
for (index in this.stores) {
emit(this.stores[index], 1);
}
}
> result = db.runCommand({
... "mapreduce" : "users",
... "map" : map,
... "reduce" : reduce,
... "out" : "tags"})
{
"assertion" : "_id cannot be an array",
"assertionCode" : 10099,
"errmsg" : "db assertion failure",
"ok" : 0
}
答案 0 :(得分:1)
"assertion" : "_id cannot be an array"
可能意味着你的this.stores [index]是一个数组,因为MapReduce结果有_id作为你的Map键