سؤال

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"
}
هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top