mongodb:如何在 mongodb shell 上调试 map/reduce [英] mongodb: how to debug map/reduce on mongodb shell
问题描述
我是 MongoDB 新手,我正在使用 map/reduce.有人可以告诉我如何在使用 map/reduce 时进行调试吗?我使用了print()"函数,但在 MongoDB shell 上,没有打印任何内容.以下是我的 reduce 函数:
I am new to MongoDB, I am using map/reduce. Can somebody tell me how to debug while using map/reduce? I used "print()" function but on MongoDB shell, nothing is printed. Following is my reduce function:
var reduce = function(key, values){
var result = {count: 0, host: ""};
for(var i in values){
result.count++;
result.host = values[i].host;
print(key+" : "+values[i]);
}
return result;
}
当我在 shell 上编写上述函数并在完成后按 Enter 时,shell 上没有打印任何内容.还有什么我应该做的调试吗?
when I write the above function on shell and the press Enter after completing, nothing gets printed on the shell. Is there anything else I should do to debug?
谢谢
推荐答案
看来reduce函数中的print()
语句是写入日志文件的,而不是shell.因此,请检查您的日志文件以获取调试输出.
It seems that print()
statements in reduce functions are written to the log file, rather than the shell. So check your log file for your debug output.
可以在启动mongod进程时使用--logpath D:path olog.txt
参数指定日志文件.
You can specify the log file by using a --logpath D:path olog.txt
parameter when starting the mongod process.
这篇关于mongodb:如何在 mongodb shell 上调试 map/reduce的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!