3

以下のような地理フィールドを含むドキュメントがあります。

"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
}

誰かが理由を教えてもらえますか?

4

1 に答える 1