pymongo聚合不允许解释选项 [英] pymongo aggregate don't allow explain option
本文介绍了pymongo聚合不允许解释选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我成功运行:
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.
因此,我尝试添加所需的选项:
Thus I try so as to add the needed option:
result = mydb.command('aggregate', 'mycol', my_pipeline, {'explain':True})
但没有说:
pymongo.errors.OperationFailure: 'pipeline' option must be specified as an array
怎么了?
谢谢您的建议.
基督徒
推荐答案
使用"pipeline"关键字参数将管道传递给"command":
Pass your pipeline using the "pipeline" keyword argument to "command":
db.command('aggregate', 'mycol', pipeline=my_pipeline, explain=True)
例如:
db.command('aggregate', 'mycol', pipeline=[{'$project': {'name': '$field'}}], explain=True)
这篇关于pymongo聚合不允许解释选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文