84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
使用db.runCommand({geoNear : “collectionName” , near : [120.123456,30.654321], num : 10 })查询之前我需要准备什么样子的集合collection ?collection相应的字段和索引???
人生最曼妙的风景,竟是内心的淡定与从容!
collection里面需要以GeoJson格式添加坐标的信息,例如:
{ type: "Point", coordinates: [ 40, 5 ] }
还需要建一个2dsphere类型的索引,例如:
db.collection.createIndex( { <location field> : "2dsphere" } )
更多细节请看mongodb的文档:https://docs.mongodb.org/manual/core/2dsphere/
collection里面需要以GeoJson格式添加坐标的信息,例如:
还需要建一个2dsphere类型的索引,例如:
更多细节请看mongodb的文档:
https://docs.mongodb.org/manual/core/2dsphere/