[SERVER-24416] $geoNear queries should fail with error if collection does not exist Created: 06/Jun/16  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Geo, Querying
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: J Rassi Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Participants:

 Description   

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.


Generated at Thu Feb 08 04:06:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.