Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-1151

Error in online docu of 2d Geospatial Indexes

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • None
    • manual
    • None
    • MongoDB 2.2

    Description

      On page http://docs.mongodb.org/manual/core/geospatial-indexes/#distance-calculation one can read:

      db.places.find( { loc: { $centerSphere: [ [ -74, 40.74 ] ,
                                                100 / 3963.192 ] } } )

      Running this command in the mongo shell produces the following error:

      error: { "$err" : "geo field only has 1 element", "code" : 13068 }

      The correct query has to be:

      db.places.find( { loc: {$within: { $centerSphere: [ [ -74, 40.74 ] ,
                                                          100 / 3963.192 ] } } })

      There needs to be a {$within: ...} wrapped around {$centerSphere: ...}.

      Attachments

        Activity

          People

            sam.kleinman Sam Kleinman (Inactive)
            defa Stefan Kreutter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              10 years, 51 weeks, 5 days ago