-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Query Language
-
None
-
Query Optimization
-
ALL
When a regex is inside an $in, the regex is actually evaluated against strings, acting like a regex match predicate rather than an equality predicate:
MongoDB Enterprise > db.c.find({a: {$in: [1, /foo/]}}) { "_id" : ObjectId("5b6b69f6c3d88f417d6971c0"), "a" : /foo/ } { "_id" : ObjectId("5b6b69fcc3d88f417d6971c1"), "a" : 1 } { "_id" : ObjectId("5b6b6a04c3d88f417d6971c2"), "a" : "foobar" }
This means that $in is not simply syntactic sugar for an $or of equalities. Another unfortunate consequence is that the $lookup join predicate cannot always be expressed as an $in; if there is a regex it must be expressed as an $or.
- is related to
-
SERVER-34012 Planner's logic for taking union of index bounds intervals is slow for large $or queries
- Closed
- related to
-
SERVER-55509 {example: /regex/} and {example: {$eq: /regex/}} do not mean the same thing
- Backlog
-
SERVER-14595 Allow {$regex: /pattern/} syntax inside $in (currently only /pattern/ syntax is allowed)
- Backlog