Details
-
Bug
-
Resolution: Fixed
-
Blocker - P1
-
None
-
None
-
Fully Compatible
-
ALL
-
v5.3
-
QE 2022-04-04, QE 2022-03-21, QE 2022-04-18
Description
In the classic engine, when $in contains a regular expression, a document matches if either 1) it stores exactly the same regex, or 2) it stores a string which matches the regex:
> db.version()
|
5.2.1
|
> db.adminCommand({setParameter: 1, internalQueryForceClassicEngine: true})
|
{ "was" : true, "ok" : 1 }
|
> db.c.drop()
|
true
|
> db.c.insert({a: "foo"})
|
WriteResult({ "nInserted" : 1 })
|
> db.c.insert({a: /foo/})
|
WriteResult({ "nInserted" : 1 })
|
> db.c.find({a: {$in: [1, /foo/]}})
|
{ "_id" : ObjectId("621ffc0239b4116350452341"), "a" : "foo" }
|
{ "_id" : ObjectId("621ffc0639b4116350452343"), "a" : /foo/ }
|
SBE, in contrast, only returns documents containing strings matching the regex. If we enable SBE and run the same query, the result set now contains just a single document instead of two documents:
> db.adminCommand({setParameter: 1, internalQueryForceClassicEngine: false})
|
{ "was" : true, "ok" : 1 }
|
> db.c.find({a: {$in: [1, /foo/]}})
|
{ "_id" : ObjectId("621ffc0239b4116350452341"), "a" : "foo" }
|
It looks like we dealt with this situation already for regex match expressions outside of a $in under SERVER-54493, but the same changes were never implemented for regexes inside of an $in.
Attachments
Issue Links
- is related to
-
SERVER-54493 [SBE] Can't match on a regexp field
-
- Closed
-