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

$geoNear queries should fail with error if collection does not exist

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Geo, Querying
    • Query Execution
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, $geoNear queries return an empty result set if the collection does not exist. These queries should return an error instead, as all $geoNear queries must be answered with an index.

      Reproduce as follows:

      > db.foo.drop()
      false
      > db.foo.find({a: {$near: [0, 0]}})  // Returns no error (unexpected).
      > db.createCollection("foo")
      { "ok" : 1 }
      > db.foo.find({a: {$near: [0, 0]}}) // Returns error (expected).
      Error: error: {
      	"waitedMS" : NumberLong(0),
      	"ok" : 0,
      	"errmsg" : "error processing query: ns=test.fooTree: GEONEAR  field=a maxdist=1.79769e+308 isNearSphere=0\nSort: {}\nProj: {}\n planner returned error: unable to find index for $geoNear query",
      	"code" : 2
      }
      

      One possible implementation strategy would be to extend ExtensionsCallback with a new method "parseGeoNear()" which returns a not-OK status if the collection does not exist.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            rassi J Rassi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: