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.
- is duplicated by
-
SERVER-13199 regex uses too strict index bounds when | is after a metacharacter
- Closed
- is related to
-
SERVER-16622 RegEx query predicates using the | (vertical bar) character cannot use tight index bounds
- Backlog
- related to
-
SERVER-20432 $regex prefix search with escaped "|" should use tighter index bounds
- Closed
-
SERVER-22872 Order by is not working in 3.2.3
- Closed
-
SERVER-22890 3.2.3 performance regression
- Closed