【发布时间】:2017-01-28 00:38:13
【问题描述】:
我正在尝试使用执行 geoNear 搜索的 PyMongo 编写对 db.command() 的调用,并且我想排除字段。 Mongo 站点上的 db.runCommand 文档和 PyMongo 文档都没有解释如何实现这一点。
我了解如何使用 db.collection.find():
response = collection.find_one(
filter = {"PostalCode": postal_code},
projection = {'_id': False}
)
但是,在使用 db.command() 执行 geoNear 搜索时,我无法在任何地方找到任何示例:
params = {
"near": {
"type": "Point",
"coordinates": [longitude, latitude]
},
"spherical": True,
"limit": 1,
}
response = self.db.command("geoNear", value=self._collection_name, **params)
谁能提供有关在使用 db.command 时如何排除字段的见解?
【问题讨论】: