【问题标题】:pymongo map-reduce not working according to the querypymongo map-reduce 无法根据查询工作
【发布时间】:2021-01-02 06:56:20
【问题描述】:

我有一个收藏:

{sentiment: "some_sentiment",
words: Array_of_words
}

我有这个地图功能:

function () {
        for (var w=0; w < this.words.length; w++) {
            emit(this.words[w], 1)
        }
        
    }

这是我的 reduce 函数:

function (word, values) {
        return Array.sum(values)
    }

这是我的电话:

collection_obj.map_reduce(map_func, reduce_func, output_collection, query={'sentiment': "some_sentiment"})

目标是按情感将文档分成不同的集合,并计算 words_array 中的单词在具有相同情感的文档中出现的次数。

这必须通过 MAP_REDUCE 来完成,不要建议聚合。

我是通过pymongo做的,map函数和reduce函数的代码是由bson的代码类编译的,我想问题可能出在我的调用,idk...

【问题讨论】:

    标签: mongodb mapreduce pymongo


    【解决方案1】:

    好的,我知道了,它的 query=query,不只是查询

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多