I am experimenting with mongoDB geoNear query. I have a Collection with one document inside:
{
"_id": {
"$oid": "583d169df18ef10012ae8345"
},
"location": {
"loc": [
103.7652117,
1.3150887
],
"name": "",
"_id": {
"$oid": "583d169df18ef10012ae8346"
}
},
}
The location.loc field is 2d indexed. Then I used a geoNear query on mongoDB command
{
"geoNear": "users",
"near": [103.761614, 1.3172431],
"num": 10
}
The result distance returned from mongoDB is 0.004193433515629152 radians which corresponds to more than 20 km. However, these 2 coordinates are just 0.5 km apart. Is there anything I have done wrong? I know it must be some very silly thing, but I just couldn't figure out.
答案 0 :(得分:0)
如果您只想查询与$geoWithin or $centerSphere or $geoNear
位置结构相关的内容: -
"location" : {
"lng" : 77.15319738236303,
"lat" : 28.434568229025803
},
然后运行您的查询。它会给你准确的结果。