[COMPASS-3932] RegEx with $options is not allowed in the $match stage Created: 16/Oct/19  Updated: 29/Oct/23  Resolved: 24/Mar/20

Status: Closed
Project: Compass
Component/s: Compass, Grammar
Affects Version/s: 1.14.6, 1.19.12
Fix Version/s: 1.22.0

Type: Bug Priority: Minor - P4
Reporter: Tanna Matan Assignee: Durran Jordan
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2019-10-16 at 9.49.00 AM.png     PNG File Screen Shot 2019-10-16 at 9.49.14 AM.png     PNG File Screen Shot 2019-10-16 at 9.49.36 AM.png     PNG File Screen Shot 2019-10-16 at 9.49.53 AM.png     PNG File Screen Shot 2019-10-16 at 9.50.04 AM.png     PNG File screenshot-1.png    
Issue Links:
Problem/Incident
causes COMPASS-4146 Disable validation in agg builder, qu... Closed
Sprint: Iteration Zebra

 Description   

RegEx with $options can be written in 4 formats as noted in this document. All of them are not allowed when using in $match stage. Compass showed error: 'Expected "[" or AggregationStage but "{" found.'. RegEx with no $options works fine.
Please see the attached images.

RegEx with $options formats do not work in $match stage:

{ <field>: { $regex: /pattern/, $options: '<options>' } }
{ <field>: { $regex: 'pattern', $options: '<options>' } }
{ <field>: { $regex: /pattern/<options> } }
{ <field>: /pattern/<options> }

Additionally, in the Query Bar, half of the formats work while another half do not work.

Work:

{ <field>: { $regex: 'pattern', $options: '<options>' } }
{ <field>: /pattern/<options> }

Not Work:

{ <field>: { $regex: /pattern/, $options: '<options>' } }
{ <field>: { $regex: /pattern/<options> } }


Generated at Wed Feb 07 22:34:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.