Mongo相关

mongo地理位置索引

LBS,存储每个地点的经纬度坐标,搜寻附近的地点,建立地理位置索引可提高查询效率。

mongodb地理位置索引,2d2dsphere,对应平面和球面。

参考 http://blog.csdn.net/fdipzone/article/details/46285521


mongo地理位置查询:


query:state:0                                                                                //查询条件

             loc:{xxxx}                                                                              //loc为point的地理位置索引

 filter {id": 1,"xxx":1,"longitude":1,"latitude":1,"status":1}  //选择哪些字段

 db.xxxx.find(
      {   "state" : 1,
          loc: { $near : { $geometry : { type : "Point" , coordinates : [120.108753, 30.300193] }  , $maxDistance : 500} }} ,
         {"id": 1,"xxx":1,"longitude":1,"latitude":1,"status":1})

参考

http://www.360sdn.com/MongoDB/2015/0413/5627.html

https://docs.mongodb.org/manual/reference/command/geoNear/

你可能感兴趣的:(mongo)