我有一个包含以下索引的集合。
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "bs.locations"
},
{
"v" : 1,
"key" : {
"location" : "2dsphere"
},
"name" : "location_2dsphere",
"ns" : "bs.locations",
"2dsphereIndexVersion" : 2
}
]
我可以插入以下文件:
db.locations.insert({ "location" : {"coordinates" : [ 6.982654547382455, 46.88414220428685 ], "type" : "Point", "test":1.0} })
但是当我尝试插入此文档时:
db.locations.insert({ "location" : {"test":1.0, "coordinates" : [ 6.982654547382455, 46.88414220428685 ], "type" : "Point"} })
我收到以下错误:
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 16755,
"errmsg" : "Can't extract geo keys: { _id: ObjectId('5566050507c10c31ce7214af'), location: { test: 1.0, coordinates: [ 6.982654547382455, 46.88414220428685 ], type: \"Point\" } } Point must only contain numeric elements"
}
})
我的问题是,我在这里想念什么?我的错误是什么?
我使用 MongoDB 版本 v3.0.1