我有一些文件,里面有一个地理字段,如下所示。
"geo" : {
"type" : "Point",
"coordinates" : [
37.44609999,
-121.88355687
]
},
我创建了一个空间索引,如下所示。
db.collection.getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "db.collection",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"geo.coordinates" : "2dsphere"
},
"ns" : "db.collection",
"name" : "geo.coordinates_2dsphere"
}
]
但是,当我执行以下查询时(从MongoDB手册逐字查询)。
db.collection.find( { 'geo.coordinates': { $near:
{ $geometry :
{ type : "Point",
coordinates: [ 37.44609999, -121.88355687 ] } },
$maxDistance: 1000
} } )
我得到以下错误。
error: {
"$err" : "$near requires geojson point, given { type: \"Point\", coordinates: [ 37.44609999, -121.88355687 ] }",
"code" : 16681
}
有人能告诉我为什么吗?
发布于 2013-09-30 16:58:36
翻转各点如下:
“地理”:{“类型”:“点”,“坐标”:-121.88355687,37.44609999 },
否则,检查您的坐标是否是真实的:http://geojsonlint.com/
https://stackoverflow.com/questions/19085840
复制相似问题