[SERVER-78511] Disallow $_internalBucketGeoWithin in $elemMatch Created: 28/Jun/23  Updated: 29/Oct/23  Resolved: 10/Oct/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: David Percy Assignee: David Percy
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QO 2023-07-24, QO 2023-08-07, QO 2023-08-21, QO 2023-09-04, QO 2023-09-18, QO 2023-10-02, QO 2023-10-16
Participants:

 Description   

When parsing a MatchExpression, we should raise a user error if we find $_internalBucketGeoWithin anywhere inside an $elemMatch.

For example, this should be a parse error:

db.foo.find({abc: {$elemMatch: {$_internalBucketGeoWithin: {field: "xyz", withinRegion: {$centerSphere: [[0, 0], 10]}}}}})

This should be an error because:

  1. A user would not write this directly: $_internalBucketGeoWithin is an internal expression for time-series.
  2. We wouldn't generate this internally, because we don't push down $elemMatch on events (if I remember correctly).
  3. $_internalBucketGeoWithin assumes that its matches() method runs on the entire document, so it wouldn't behave correctly inside $elemMatch anyway.
    • One reason it expects to be given the entire document, is that it can read from the bucket's control field. It can use the min/max values to create a bounding region.


 Comments   
Comment by Githook User [ 09/Oct/23 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-78511 Disallow $_internalBucketGeoWithin in $elemMatch

This internal geo operator assumes it runs against a whole input
document, so the MatchExpression parser should enforce that.
Other operators such as $where and $expr already have this restriction;
this commit uses the same mechanism for $_internalBucketGeoWithin.
Branch: master
https://github.com/mongodb/mongo/commit/e97504cf0006967aafffb8cb1e8f89b8ce6e73e1

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