Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14595

Allow {$regex: /pattern/} syntax inside $in (currently only /pattern/ syntax is allowed)

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 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.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            stephen.lee Stephen Lee
            Votes:
            7 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: