发布于 2015-09-14 15:07:38 | 197 次阅读 | 评论: 0 | 来源: 网络整理
1.8 新版功能.
The $nearSphere operator is the spherical equivalent of the $near operator. $nearSphere returns all documents near a point, calculating distances using spherical geometry.
db.collection.find( { loc: { $nearSphere: [0,0] } } )
在 2.2.3 版更改: Before 2.2.3, a geospatial index must exist on a field holding coordinates before using any of the geolocation query operators. After 2.2.3, applications may use geolocation query operators without having a geospatial index; however, geospatial indexes will support much faster geospatial queries than the unindexed equivalents.
注解
A geospatial index must exist on a field and the field must hold coordinates before you can use any of the geolocation query operators.