2016-05-07 6 views
1

私はこのような文書の大規模なセットがあります。なぜ2Dインデックスが機能しないのですか?

{ 
    "_id" : ObjectId("572e33baf082e29c46cadb7b"), 
    "nodes" : [ 
     [ 
      39.2035598754883, 
      51.6601028442383 
     ], 
     [ 
      39.2038421630859, 
      51.6602439880371 
     ], 
     [ 
      39.2038688659668, 
      51.6602249145508 
     ] 
    ] 
} 

をそして私は座標で文書を検索したいです。私のクエリは次のとおり

db.points.find({ノード:{$ elemMatch:{$ geoWithin: {$ボックス:[39.1981、51.660]、[39.206、51.664]]}}}})

Iは、インデックス

db.points.createIndex({ "ノード": "2D"})を添加

が、それは効果がありません。コレクションの統計:

{ 
    "ns" : "base.points", 
    "count" : 215583, 
    "size" : 61338720, 
    "avgObjSize" : 284, 
    "storageSize" : 86310912, 
    "numExtents" : 10, 
    "nindexes" : 3, 
    "lastExtentSize" : 27869184, 
    "paddingFactor" : 1.0, 
    "systemFlags" : 0, 
    "userFlags" : 1, 
    "totalIndexSize" : 39759888, 
    "indexSizes" : { 
     "_id_" : 7006832, 
     "nodes_2d" : 26719168 
    }, 
    "ok" : 1.0 
} 

し、説明:

{ 
    "cursor" : "BasicCursor", 
    "isMultiKey" : false, 
    "n" : 61, 
    "nscannedObjects" : 215583, 
    "nscanned" : 215583, 
    "nscannedObjectsAllPlans" : 215583, 
    "nscannedAllPlans" : 215583, 
    "scanAndOrder" : false, 
    "indexOnly" : false, 
    "nYields" : 1684, 
    "nChunkSkips" : 0, 
    "millis" : 1466, 
    "server" : "DEVELOP-PC:27017", 
    "filterSet" : false 
} 

答えて

0

を解決は非常に簡単だった:

db.points.find({ノード:{$ geoWithin:{$ボックス:[ [39.1981,51.660]、 [39.206,51.664]}}})

は、 ery $elemMatchとインデックスが正しく動作します

関連する問題