-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.4.10, 2.6.3, 2.7.3
-
Component/s: Querying
-
Query Optimization
The following two queries should be equivalent:
coll.find({a: {$in: [/abc/]}}) coll.find({a: {$in: [{$regex: /abc/}]}})
However, in 2.6.3 the former succeeds and the latter fails with "Can't canonicalize query: BadValue cannot nest $ under $in". We should support both forms of this query.
Original Description
Per this documentation, I assume that querying with the $in operator upon a list of regular expressions using either form of regular expression syntax, /^pattern/ or {$regex: "^pattern"}, is equivalent. However, the latter $regex operator syntax doesn't work.
v2.4.10 returns no documents, but v2.6.3 returns the 17287 error.
v2.7 nightly (mongodb-osx-x86_64-2b55561913f26870b0d4b1c8ec180139819eeba6-2014-07-16) also returns the 17287 error.
- is related to
-
SERVER-55639 $in with regex has special meaning
- Backlog
- related to
-
SERVER-13779 Allow $not to be applied to $regex (currently only /regex/ syntax is allowed)
- Closed