why i make a 2dsphere index ,but when i query it shows s2cursor?

拜拜、爱过 提交于 2020-01-03 05:47:08

问题


why i make a 2dsphere index ,but when i query it shows s2cursor, i think it should be geosearchcursor. the mongodb document says this: http://docs.mongodb.org/manual/reference/method/cursor.explain/#explain-output-fields-core

cursor is a string that reports the type of cursor used by the query operation:

BasicCursor indicates a full collection scan. BtreeCursor indicates that the query used an index. The cursor includes name of the index. When a query uses an index, the output of explain() includes indexBounds details. GeoSearchCursor indicates that the query used a geospatial index.

my document:

{
    "_id" : "b2lblohv6qvcwzd6o2pcqep8v0",
    "eventid" : "b2lblohv6qvcwzd6o2pcqep8v0",
    "loc" : {
        "type" : "Point",
        "coordinates" : [
            -122.4127337,
            37.7709975
        ]
    },
    "end" : 1379399400,
    "start" : 1379392200,
}

this is my mongodb shell output:

> db.collection_ca1.ensureIndex({'loc':'2dsphere'})

> db.collection_ca1.find({'loc':{'$geoWithin':{'$centerSphere':[[-118.397264,34.019763], 0.00001]}}}).explain()
{
    "cursor" : "S2Cursor",
    "isMultiKey" : true,
    "n" : 1979,
    "nscannedObjects" : 1979,
    "nscanned" : 25482,
    "nscannedObjectsAllPlans" : 1979,
    "nscannedAllPlans" : 25482,
    "scanAndOrder" : false,
    "indexOnly" : false,
    "nYields" : 6,
    "nChunkSkips" : 0,
    "millis" : 12215,
    "indexBounds" : {

    },
    "nscanned" : 25482,
    "matchTested" : NumberLong(23503),
    "geoTested" : NumberLong(23503),
    "cellsInCover" : NumberLong(1),
    "server" : "localhost:27017"
}

回答1:


That documentation has not been updated for the '2dsphere' index added in 2.4.

The S2Cursor is the optimized search for a '2dsphere' index.

You should file a Jira ticket to the DOCS project to get it updated: https://jira.mongodb.org/browse/DOCS



来源:https://stackoverflow.com/questions/19969405/why-i-make-a-2dsphere-index-but-when-i-query-it-shows-s2cursor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!