我成功运行:
result = my_col.aggregate(my_pipeline, allowDiskUse=True)
现在当我尝试时:
result = my_col.aggregate(my_pipeline, allowDiskUse=True, explain=True)
它失败了:
pymongo.errors.ConfigurationError: The explain option is not supported. Use Database.command instead.
因此我尝试添加所需的选项:
result = mydb.command('aggregate', 'mycol', my_pipeline, {'explain':True})
但它没有说:
pymongo.errors.OperationFailure: 'pipeline' option must be specified as an array
怎么了?
感谢您的任何建议。
基督教
使用“pipeline”关键字参数将管道传递给“command”:
db.command('aggregate', 'mycol', pipeline=my_pipeline, explain=True)
例如:
db.command('aggregate', 'mycol', pipeline=[{'$project': {'name': '$field'}}], explain=True)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)