数据库字段是这样的
"location_geo": {
"coordinates": [
122.029863,
31.241123
],
"type": "Point"
}
索引
_locationgeo
非唯一
否
location_geo 升序
查询语句,官方文档的
await db.collection('uni-id-users').aggregate().geoNear({
distanceField: 'distance',
spherical: true,
near: new db.Geo.Point(116.397689, 39.904626), // 人民英雄纪念碑
maxDistance: 500,
key:'location_geo'
}).field('_id,nickname,location_geo').end()
查询结果error
Command failed with error 291 (NoQueryExecutionPlans): 'error processing query:
麻烦问一下,哪里问题
![tangyx](http://img-cdn-tc.dcloud.net.cn/uploads/avatar/000/12/00/24_avatar_mid.jpg?v=1652499827)
tangyx
- 发布:2024-06-13 17:58
- 更新:2024-06-13 18:09
- 阅读:175
1 个回复
tangyx (作者)
已解决,是索引问题。忽略