[英]Dictionary of dictionary - python Mongo Db
我想要找到价值 - db.mycol.find({"title":"Reuters"})
{'_id': ObjectId('63b8dfbfd651efc35007b66c'), '18998750': {'pageid': 18998750, 'ns': 0, 'title': 'Reuters', 'extract': 'Reuters ( (listen), ROY-terz) is a news agency owned by Thoms
db = clu["Collections"]
col = db["wik"]
col.find({"title":"Reuters"})
结果 - 无。
您必须使用点符号来获得您要查找的内容。 是这样的:
col.find({"18998750.title":"Reuters"})
在此查询中,您要查询的是文档,其中 18998750 是一个 object,看起来像{"title": "Reuters"}
,因此如果您知道整个子文档,则此方法有效。
这里有几个相关的问题:
使用 collection.find() 在 pymongo 中嵌套查询
和一些参考资料:
https://www.tutorialspoint.com/using-find-to-search-for-nested-keys-in-mongodb
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.