确保有loc:[longitude, latitude]属性
给loc增加索引AttractionSchema.index({loc: '2d'});
使用geoNear
db.places.find(
{
location: {
$nearSphere: {
$geometry: {
type : "Point",
coordinates : [ -73.9667, 40.78 ]
},
$minDistance: 1000,
$maxDistance: 5000,

}
}
}
)


spherical: true

 posted on 2016-09-19 09:33  jayruan  阅读(220)  评论(0编辑  收藏  举报