小编Ale*_*rdi的帖子

'Collection'对象不可调用.如果你打算在'Collection'对象上调用'mapReduce'方法,它就会失败,因为不存在这样的方法

我正在使用pyMongo 1.11和MongoDB 1.8.2.我正在尝试做一个相当复杂的Map/Reduce.我在Mongo中对函数进行了原型设计并使其正常工作,但是当我尝试将其转换为Python时,我得到:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/Developer/R-and-D/<ipython-input-71-3c3a43221538> in <module>()
----> 1 results = db.user_actions.mapReduce(map, reduce, "user_entities_interactions")

/Library/Python/2.7/site-packages/pymongo/collection.pyc in __call__(self, *args, **kwargs)
   1099                         "call the '%s' method on a 'Collection' object it is "
   1100                         "failing because no such method exists." %
-> 1101                         self.__name.split(".")[-1])

TypeError: 'Collection' object is not callable. If you meant to call the 'mapReduce' method on a 'Collection' object it is failing because no such method exists.
Run Code Online (Sandbox Code Playgroud)

我的收藏看起来像这样:

{ "_id" : ObjectId("..."), "entity_id" …
Run Code Online (Sandbox Code Playgroud)

python mapreduce mongodb pymongo

4
推荐指数
2
解决办法
1万
查看次数

标签 统计

mapreduce ×1

mongodb ×1

pymongo ×1

python ×1