python - Pymongo $geoWithin 查询不返回任何文档
问题描述
我正在使用 $geoWithin 运算符查询 MongoDB 集合,但没有收到任何文档作为响应。
这是我数据库中的示例文档:
{
"_id": {
"$oid": "608a2296594b7e54c0067426"
},
"properties": {
"id": "MONR365005",
"unit": "Unit 2",
"number": "94",
"street": "Crittenden Way",
"city": "Brighton",
"district": "Monroe",
"region": "NY",
"postcode": "14623",
"hash": "3d8b0721e06b6ad8",
"Realtor_ID": 0
},
"location": {
"type": "Point",
"coordinates": [43.1016143, -77.6340374]
}
}
这是我要执行的查询:
nearest = self.geoCoords.aggregate([{"$match": {"location": {
"$geoWithin": {"$centerSphere": [[start[0], start[1]], self.distance_radians(self.feet_meter(radius))]}}}}])
print(list(nearest))
如何解决此问题以使查询返回正确数量的文档?非常感谢!
解决方案
推荐阅读
- java - Spring Boot - 配置弹性搜索
- kubernetes - Kubernetes 多端口服务:无法从客户端 pod 连接到 influxdb 中的石墨端口
- c++ - 如何使用 C++ 中的插件将 VBA 添加到 Excel?
- java - 为什么`弱一致迭代器`只反映修改和删除的变化,而不反映插入的变化
- protractor - element.all 总是返回计数为 0
- c# - 处理错误 PInvokeStackImbalance
- java - Kafka --from-begining CLI vs Kafka Java API
- c - 如何使用 SIGINT 从选择中返回
- javascript - iframe 获取父屏幕高度
- angular - 单元测试是否已在 Angular/Redux 中清除所有订阅