看来这是个 月球虫 。
将查询更改为 使用GeoJSON
对象而不是坐标对,例如:
qry.where('loc').near({ center: { type: 'Point', coordinates: search.loc }, maxDistance: search.distance * 1000});导致以下查询:
Mongoose: models.find({ loc: { '$near': { '$maxDistance': 1, '$geometry': { type: 'Point', coordinates: [ 10, -20 ] } } } }) { fields: undefined }现在搜索成功。
该文档使用坐标对显式显示查询:
query.where('loc').near({ center: [10, 10], maxDistance: 5 });但是,这似乎不起作用,示例应为:
query.where('loc').near({ center: { coordinates: [10, 10], type: 'Point' }, maxDistance: 5 });


