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.