これは重複した質問ではありませんもう 1 つの質問は、Mongo 2.4 とは大きく異なる集合体である Mongo 2.6 に関するものです。私はすでに他の質問を読んでおり、この質問の最後の段落でも取り上げています。
まず、私は Mongo の初心者であり、PyMongo の初心者です。既存のスクリプトを使用しており、ローカルで実行されない理由をデバッグしようとしています。次のクエリはエラーになります。
クエリ:
[{
u'$match': {
u'geocode.co_iso2': u'US',
u'brand._id': UUID('xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')
}
},
{
u'$group': {
u'_id': u'$brand._id',
u'num': {u'$sum': 1}
}
},
{
u'$sort': {u'num': -1}
},
{
u'$limit': 100000
}]
コード:
cursor = yield db[collection].aggregate(bsonQuery)
self.write(bson.json_util.dumps(cursor))
エラー:
Exception: <class 'tornado.gen.BadYieldError'>:yielded unknown object MotorAggregationCursor(<motor.core._LatentCursor object at 0x10a897b50>)
また、これが Mongo 2.4 と PyMongo 2.8 であることにも注意してください。同様のエラーが発生した一部の人々は、cursor
なしで保存してyield
から を実行するように言われていwhile(yield...)
ます。試してみましたが、Mongo 2.4 には適用できないようです。次のように述べています。
Exception: <class 'pymongo.errors.OperationFailure'>:command SON([('aggregate', u'MyCollection'), ('pipeline', [{u'$match': {u'geocode.co_iso2': u'US', u'brand._id': UUID('xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')}}, {u'$group': {u'_id': u'$brand._id', u'num': {u'$sum': 1}}}, {u'$sort': {u'num': -1}}, {u'$limit': 100000}]), (u'cursor', {})]) on namespace mydatabase.$cmd failed: unrecognized field "cursor