1

In my mongodb Collection I have a 2dsphere index

{ "ns" : "PanPanDB.posts", "key" : { "location_2dsphere" : "2dsphere" }, "name" : "location_2dsphere_2dsphere", "background" : true, "safe" : null, "unique" : false }

When I query on it I obtain the following error:

> db.posts.find( { "location_2dsphere" :{ $near : {$geometry:    { type : "Point" , coordinates : [ 100 , 5 ] } , $maxDistance : 1000}}}  )
error: {
    "$err" : "can't find special index: 2d for: { location_2dsphere: { $near: { $geometry: { type: \"Point\", coordinates: { 0: 100.0, 1: 5.0 } }, $maxDistance: 1000.0 } } }"
}

Can you help me? There isn't much documentation on the web!

4

1 回答 1

3

假设您使用的是 ubuntu,默认的 apt-get install mongodb-server 会为您提供不支持 2dsphere 索引的 mongodb 2.2 版本。

您可能要考虑升级到 2.4:http ://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

于 2013-07-28T14:20:15.113 回答