Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-16144

geoSpatial search returns error 16885 if collection has no document with specified location field

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • ALL
    • Hide

      2dsphere index defined on some filed ( "loc" ):

             {
                     "v" : 1,
                     "key" : {
                             "loc" : "2dsphere"
                     },
                     "name" : "loc_2dsphere",
                     "ns" : "mydb.mycoll",
                     "2dsphereIndexVersion" : 2
             }

      collection has many documents but none of them has loc
      run find():

      db.mycoll.find( { loc : { $near : { $geometry : { type : "Point" , coordinates : [ 100.0, 100.0 ] } } } } )

      Show
      2dsphere index defined on some filed ( "loc" ): { "v" : 1, "key" : { "loc" : "2dsphere" }, "name" : "loc_2dsphere", "ns" : "mydb.mycoll", "2dsphereIndexVersion" : 2 } collection has many documents but none of them has loc run find(): db.mycoll.find( { loc : { $near : { $geometry : { type : "Point" , coordinates : [ 100.0, 100.0 ] } } } } )

    Description

      2dSphere index is built on the "loc" field. If collection has number of documents but none of the documents has the "loc" field, the geospatial find() against this collection will return $err 16885 : $near requires a point given.

      Expected result empty cursor.

      Non geospatial searches on non existing fields return empty cursors.

      Attachments

        Activity

          People

            ramon.fernandez@mongodb.com Ramon Fernandez Marina
            lalexl Alexey Lischinsky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: