mongodb geonear
黄舟
黄舟 2017-05-02 09:17:53
0
1
471
使用db.runCommand({geoNear : “collectionName” , near : [120.123456,30.654321], num : 10 })查询之前我需要准备什么样子的集合collection ?collection相应的字段和索引???
黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回复(1)
大家讲道理

collection里面需要以GeoJson格式添加坐标的信息,例如:

{ type: "Point", coordinates: [ 40, 5 ] }

还需要建一个2dsphere类型的索引,例如:

db.collection.createIndex( { <location field> : "2dsphere" } )

更多细节请看mongodb的文档:
https://docs.mongodb.org/manual/core/2dsphere/

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!