Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-3932

RegEx with $options is not allowed in the $match stage

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.22.0
    • Affects Version/s: 1.14.6, 1.19.12
    • Component/s: Compass, Grammar
    • None
    • Iteration Zebra

      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> } }
      

        1. Screen Shot 2019-10-16 at 9.50.04 AM.png
          Screen Shot 2019-10-16 at 9.50.04 AM.png
          121 kB
        2. Screen Shot 2019-10-16 at 9.49.53 AM.png
          Screen Shot 2019-10-16 at 9.49.53 AM.png
          45 kB
        3. Screen Shot 2019-10-16 at 9.49.36 AM.png
          Screen Shot 2019-10-16 at 9.49.36 AM.png
          49 kB
        4. Screen Shot 2019-10-16 at 9.49.14 AM.png
          Screen Shot 2019-10-16 at 9.49.14 AM.png
          51 kB
        5. Screen Shot 2019-10-16 at 9.49.00 AM.png
          Screen Shot 2019-10-16 at 9.49.00 AM.png
          51 kB
        6. screenshot-1.png
          screenshot-1.png
          53 kB

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            tanna.matan@mongodb.com Tanna Matan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: