`
langzhe
  • 浏览: 279045 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

mongdb "errmsg" : "exception: 'out' has to be a string or an object"

 
阅读更多

解决"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

}

 

0
3
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics