0
> version()
version: 2.0.4
can't find special index: 2d for: { location: { $near: { $geometry: { type: "Point", coordinates: [ 0.1, 0.1 ] } }, $maxDistance: 5000.0 } }
> version()
version: 2.0.4
can't find special index: 2d for: { location: { $near: { $geometry: { type: "Point", coordinates: [ 0.1, 0.1 ] } }, $maxDistance: 5000.0 } }
> db.syncsnapshotsphere.find()
{ "_id" : "naga", "location" : { "type" : "Point", "coordinates" : [ 0.1, 0.1 ] }, "timestamp" : 1375778757.568005 }
{ "_id" : "nagb", "location" : { "type" : "Point", "coordinates" : [ 0.2, 0.2 ] }, "timestamp" : 1375778792.552187 }
{ "_id" : "nagc", "location" : { "type" : "Point", "coordinates" : [ 0.3, 0.3 ] }, "timestamp" : 1375778803.047879 }
{ "_id" : "nagd", "location" : { "type" : "Point", "coordinates" : [ 0.4, 0.4 ] }, "timestamp" : 1375778814.088595 }
> db.syncsnapshotsphere.find({location: {$near: {$geometry: {type: "Point", coordinates: [0.1,0.1]}}, $maxDistance: 5000}})
error: {
    "$err" : "can't find special index: 2d for: { location: { $near: { $geometry: { type: \"Point\", coordinates: [ 0.1, 0.1 ] } }, $maxDistance: 5000.0 } }",
    "code" : 13038
}

2行目の「バージョン...」の直後の奇妙な「特別なインデックスが見つかりません...」が実際に出力されます...理由はわかりません。

場所フィールドに 2dsphere インデックスが既に存在する 2d インデックスを見つけようとしているというエラーが表示される理由を理解しようとしています...すべての助けに感謝します。

> db.syncsnapshotsphere.getIndexes()
[
    {
        "v" : 1,
        "key" : {
            "_id" : 1
        },
        "ns" : "logging_stuff.syncsnapshotsphere",
        "name" : "_id_"
    },
    {
        "v" : 1,
        "key" : {
            "location" : "2dsphere"
        },
        "ns" : "logging_stuff.syncsnapshotsphere",
        "name" : "location_2dsphere",
        "background" : false,
        "dropDups" : false
    }
]
> 
4

1 に答える 1

1

2dsphereMongoDB 2.4 で導入されたインデックス タイプで、2.0.4 を使用しています。2.0.x で geo クエリを実行しているため、MongoDB は2dインデックスを想定しています。MongoDB を 2.4.x にアップグレードしてください。これで問題なく動作します。

于 2013-08-06T11:08:07.823 に答える