[SERVER-22630] $match should handle geo predicates in a consistent fashion Created: 16/Feb/16  Updated: 06/Dec/22  Resolved: 26/Jul/19

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Benjamin Murphy Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 0
Labels: query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query
Participants:

 Description   

In document_source_match.cpp, "uassertNoDisallowedClauses" is used to validate the query passed into a $match stage. It confirms that $where, $near, and $nearSphere are not used inside the object, but does not check for $geoNear. It should either error in all cases, or allow geo predicates inside a $match.



 Comments   
Comment by David Storch [ 26/Jul/19 ]

This refers to old code that no longer exists for DocumentSourceMatch. It appears that recent versions correctly reject $geoNear predicates in a $match:

MongoDB Enterprise > db.c.aggregate([{$addFields: {a: "$b"}}, {$match: {loc: {$geoNear: [0, 0]}}}])
2019-07-26T16:30:05.101-0400 E  QUERY    [js] uncaught exception: Error: command failed: {
	"ok" : 0,
	"errmsg" : "$geoNear, $near, and $nearSphere are not allowed in this context",
	"code" : 2,
	"codeName" : "BadValue"
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:18:14
_assertCommandWorked@src/mongo/shell/assert.js:584:17
assert.commandWorked@src/mongo/shell/assert.js:674:16
DB.prototype._runAggregate@src/mongo/shell/db.js:267:9
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1013:12
@(shell):1:1

Closing as Gone Away.

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