Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-15235

Regex query returns incorrect results when index is present

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Done
    • 2.4.11, 2.6.3, 2.7.6
    • 2.8.0-rc1
    • Querying
    • None
    • ALL
    • Hide

      See regex_different_results_with_index.js

      Show
      See regex_different_results_with_index.js

    Description

      We've noticed a strange issue where a regex query on a field returns different results, depending on whether there is an index defined on that field or not.

      I've included a JS test file (regex_different_results_with_index.js) which reproduces the issue.

      The regex is left-anchored. Also, an equavilent regex expression (included in JS) works in both cases:

      • /^(a(a|$)|b)/ : works both with and without index
      • /^a(a|$)|^b/ : works without an index, does not work with an index

      Looking at the regex expression, the result without the index (both "aa" and "bb" match) should be the correct one. When the index is present, only "aa" is returned, which is incorrect.

      I have tested this on 2.4.11 and 2.6.3.

      Attachments

        Issue Links

          Activity

            People

              david.storch@mongodb.com David Storch
              victor.hooi Victor Hooi
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: