MongoDB笔记十——空间索引
添加2D索引
db.map.ensureIndex({gis:"2d"},{min:-1,max:201})
默认或建立一个[-180,180]之间的2D索引
查询电(70,180)最近的3个点
db.map.find({gis:{$near:[70,180]}},{gis:1,_id:0}).limit(3)

查询一点(50,50)和点(190,190)为对角线的正方形中的所有点
db.map.find({gis:{$within:{$box:[[50,50],[190,190]]}}},{_id:0,gis:1})

查询以圆心为(56,80),半径为50规则下的圆心面积中心的点
db.map.find({gis:{$within:{$center:[[]56,80],50]}}},{_id:0,gis:1})

标题名称:MongoDB笔记十——空间索引
网站网址:http://scyanting.com/article/ieegeh.html