我是 mongodb 的新手,我一直在使用 pymongo 版本 3.8.0 和 jupyter Notebook 学习一些方法。一直进展顺利,直到我尝试了 "$lookup" 方法,现在它开始抛出错误 操作失败:无权在聚合上执行命令。任何有关解决问题的帮助/建议将不胜感激。
我已经尝试重新安装软件包,并启用Windows管理权限,但到目前为止还没有解决问题
OperationFailure: not authorized on aggregations to execute command
{ aggregate: "air_routes", pipeline: [ { $match: { airplane: { $regex: "747|380" } } }, { $lookup: { from: "air_alliance", localField: "airline.name", foreignField: "airlines", as: "data_src" } },
{ $unwind: "$data_src" }, { $group: { _id: { name: "$name", airlines: "$airlines" }, numberofflights: { $sum: 1 } } }, { $sort: { numberofflights: -1 } },
{ allowDiskUse: true } ], cursor: {}, lsid: { id: UUID("af942a3d-309b-4cd2-a99b-3ebcd60406f4") }, $clusterTime: { clusterTime: Timestamp(1557101096, 1),
signature: { hash: BinData(0, AD50B7BE136F58D794C75C6AD031E92168EF61D1), keyId: 6627672121604571137 } }, $db: "aggregations", $readPreference: { mode: "primary" } }
请帮助解决此问题。谢谢,
最佳答案
好吧,我找到了答案,显然,这是与权限相关的问题,对数据库的第二次调用(数据库存储在 atlas 集群上)正在传递一些参数(显然),这些参数要么为空,要么为未正确获取,原因尚不清楚。因此,第二个收集集“air_alliance”正在重现该错误。
这里给出了一个有用的线程 https://jira.mongodb.org/browse/CSHARP-1722
关于python - 操作失败: Not authorized on aggregations to execute the command,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55997537/