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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: 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 ] } } } } )
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Ramon Fernandez
            Reporter:
            Alexey Lischinsky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: