【问题标题】:What does the data in the MongoDB Map Reduce operation output mean? Is it possible to hide it?MongoDB Map Reduce操作输出中的数据是什么意思?可以隐藏吗?
【发布时间】:2018-09-16 16:51:41
【问题描述】:

所以我使用 Map-Reduce 范式来操作 MongoDB 集合并收到以下输出:

/* 1 */
{
"results" : [ 
    {
        "_id" : "B00000IKQD",
        "value" : 4.0
    }
],
"timeMillis" : 14.0,
"counts" : {
    "input" : 3,
    "emit" : 3,
    "reduce" : 1,
    "output" : 1
},
"ok" : 1.0,
"_o" : {
    "results" : [ 
        {
            "_id" : "B00000IKQD",
            "value" : 4.0
        }
    ],
    "timeMillis" : 14,
    "counts" : {
        "input" : 3,
        "emit" : 3,
        "reduce" : 1,
        "output" : 1
    },
    "ok" : 1.0
},
"_keys" : [ 
    "results", 
    "timeMillis", 
    "counts", 
    "ok"
],
"_db" : {
    "_mongo" : {
        "slaveOk" : true,
        "host" : "localhost:27017",
        "defaultDB" : "test",
        "_readMode" : "commands"
    },
    "_name" : "vg"
    }
}

所以我在第一个数组“结果”中得到了它,它显示了我请求的输出,但之后有很多处理过的代码。

另外,有没有办法在输出中隐藏所有这些?

编辑:

因此,根据@AlexBlex 的回答,我只是添加了“.results”作为操作的结束,就像这样(而且效果很好):

db.P14165162_reviews.mapReduce(x, reduce,{
    out:{inline:1},
     query:{mts_asin:"B00000IKQD"},

}).results;  

【问题讨论】:

    标签: mongodb nosql robo3t


    【解决方案1】:

    输出记录在https://docs.mongodb.com/manual/reference/command/mapReduce/#output

    要“隐藏所有这些”,您可以只返回结果:

    db.collection.mapReduce(......).results 
    

    【讨论】:

    • 就这么简单!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-19
    • 2018-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多