mongdb "errmsg" : "exception: 'out' has to be a string or an object"
程序员文章站
2022-07-15 23:02:01
...
解决"errmsg" : "exception: 'out' has to be a string or an object"
map=function (){ for(var key in this){ emit(key, {count:1}); }}
reduce=function (key, emits){ total=0; for(var i in emits){ total+=emits[i].count; } return{"count":total}; }
> r=db.runCommand({"mapreduce":"users", "map":map,"reduce":reduce})
{
"errmsg" : "exception: 'out' has to be a string or an object",
"code" : 13606,
"ok" : 0
}
在mongodb-src-r2.4.5版本中需要指定out才能正常查询数据
> r=db.runCommand({"mapreduce":"users", "map":map,"reduce":reduce,"out":"sss"})
{
"result" : "sss",
"timeMillis" : 6,
"counts" : {
"input" : 3,
"emit" : 12,
"reduce" : 4,
"output" : 4
},
"ok" : 1
}
推荐阅读
-
JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.JsonM
-
mongdb "errmsg" : "exception: 'out' has to be a string or an object"
-
JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.JsonM