首页 > 解决方案 > MongoDB 和 Robo 3T - 错误“无法将 mapReduce 结果输出到内部数据库管理员”/“Location31321”

问题描述

我目前正在学习如何处理 MongoDB。

不幸的是,我无法执行 mapReduce 函数,而且我绝对没有找到有关该错误的任何信息:

错误信息

errmsg:“无法将 mapReduce 结果输出到内部数据库管理员”

代号:“位置31321”

有没有人知道我可以做些什么来解决这个问题?

这是我的代码(我的同事对此没有任何问题):

db.courses.mapReduce(
    function(){emit(this.course, this.hours);},
    function(key, hours) {return Array.sum(hours)},
    {
        query: {semester: 1},
        out: "totals"
    }
)
db.totals.find()

提前非常感谢!

标签: mongodbmapreducerobo3t

解决方案


我有同样的错误。我没有做“使用管理员”,而是切换到另一个名称的数据库,它对我有用。

使用“使用管理员”:

> db.Eleves.mapReduce(map, reduce, {out : "total_masculin"});
Error: map reduce failed:{
        "ok" : 0,
        "errmsg" : "Can't output mapReduce results to internal DB admin",
        "code" : 31321,
        "codeName" : "Location31321"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DBCollection.prototype.mapReduce@src/mongo/shell/collection.js:1093:15
@(shell):1:1

切换数据库:

> use labo1
switched to db labo1

在这个数据库中重新创建我的集合之后:

> db.Eleves.mapReduce(map, reduce, {out : "total_masculin"});
{ "result" : "total_masculin", "ok" : 1 }

推荐阅读