我在Robomongo / cli中使用此查询来获取最接近给定坐标的记录,该记录正常工作。
以下是使用查找
的查询db.places.find(
{
loc : {
$near : {
$geometry : {
type : "Point" ,
coordinates : [12.974729, 77.609375]
},
$maxDistance : 2000
}
}
}
);
JSON
{
"_id" : ObjectId("56c6becd8586e7a757260d62"),
"name" : "address here",
"loc" : {
"type" : "Point",
"coordinates" : [
12.9802900000000001,
77.5857400000000013
]
}
}
{
"_id" : ObjectId("56d002a7ce57e202b2cd43ea"),
"name" : "address 2",
"loc" : {
"type" : "Point",
"coordinates" : [
12.9751499999999993,
77.6248930000000001
]
}
}
现在我如何获得均匀的距离。我使用以下查询但是给了我 errmsg “找不到ns”
db.runCommand( {
geoNear: "places" ,
near: { type: "Point", coordinates: [12.974729, 77.609375] },
spherical: true,
maxDistance: 2000
})