これは重複した質問ではありませんもう1つの質問は、Mongo 2.6とは大きく異なります。私は既にもう一つの質問を読んだことがあります。この質問の最後の段落でもそれに取り組んでいます。MongoDB 2.4集計エラー:不明なオブジェクトが返されましたMotorAggregationCursor
ファーストオフ、私はモンゴでは非常に新しく、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))
エラー:
私もこれはモンゴ2.4とPyMongo 2.8であることに注意したいException: <class 'tornado.gen.BadYieldError'>:yielded unknown object MotorAggregationCursor(<motor.core._LatentCursor object at 0x10a897b50>)
。私は同じようなエラーのある人は、yield
を除いてcursor
を保存してから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