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

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: 2.4.10, 2.6.3, 2.7.3
    • Fix Version/s: Backlog
    • Component/s: Querying

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              stephen.lee Stephen Lee
              Participants:
              Votes:
              7 Vote for this issue
              Watchers:
              13 Start watching this issue

                Dates

                Created:
                Updated: