mongodb:如何在mongodb shell上调试map / reduce [英] mongodb: how to debug map/reduce on mongodb shell

查看:284
本文介绍了mongodb:如何在mongodb shell上调试map / reduce的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MongoDB的新手,我正在使用map / reduce。
有人告诉我如何在使用map / reduce时进行调试?我使用print()功能,但是在MongoDB shell中,没有打印任何内容。以下是我的减少函数:

  var reduce = function(key,values){
var result = {count: 0,host:};

(var i in values){
result.count ++;
result.host = values [i] .host;
print(key +:+ values [i]);
}
返回结果;
}

当我在shell上写上述功能,按完成后按Enter键,没有被打印在外壳上。还有什么我应该做的调试?



谢谢

解决方案

似乎 reduce() reduce函数中的语句被写入日志文件,而不是shell。因此,请检查您的日志文件以获取调试输出。



您可以使用 - logpath D:\path\指定日志文件在启动mongod进程时,请参阅to\log.txt 参数。


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;
    }

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?

Thanks

解决方案

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.

You can specify the log file by using a --logpath D:\path\to\log.txt parameter when starting the mongod process.

这篇关于mongodb:如何在mongodb shell上调试map / reduce的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆