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> } }
- causes
-
COMPASS-4146 Disable validation in agg builder, query bar and schema validation
- Closed