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

Regex with "x" option explain fails with index on target field in 2.4

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 2.4.9
    • Querying
    • ALL

    Description

      In 2.4.9 it seems that if you do a regex query with an index on the field that you are querying against and you have the "x" options enabled, you will get an error when doing an explain.

      Not certain how widespread this behavior is, as I have not looked into it very closely.

      > mydb.test.find({c: {$regex: "", $options: "x"}})
      > mydb.test.find({c: {$regex: "", $options: "x"}}).explain()
      {
              "cursor" : "BasicCursor",
              "isMultiKey" : false,
              "n" : 0,
              "nscannedObjects" : 0,
              "nscanned" : 0,
              "nscannedObjectsAllPlans" : 0,
              "nscannedAllPlans" : 0,
              "scanAndOrder" : false,
              "indexOnly" : false,
              "nYields" : 0,
              "nChunkSkips" : 0,
              "millis" : 0,
              "indexBounds" : {
       
              },
              "server" : "localhost.localdomain:28000"
      }
      > mydb.test.ensureIndex({a:1})
      Cannot use commands write mode, degrading to compatability mode
      WriteResult({ "nInserted" : 1 })
      > mydb.test.find({c: {$regex: "", $options: "x"}})
      > mydb.test.find({c: {$regex: "", $options: "x"}}).explain()
      {
              "cursor" : "BasicCursor",
              "isMultiKey" : false,
              "n" : 0,
              "nscannedObjects" : 0,
              "nscanned" : 0,
              "nscannedObjectsAllPlans" : 0,
              "nscannedAllPlans" : 0,
              "scanAndOrder" : false,
              "indexOnly" : false,
              "nYields" : 0,
              "nChunkSkips" : 0,
              "millis" : 0,
              "indexBounds" : {
       
              },
              "server" : "localhost.localdomain:28000"
      }
      > mydb.test.ensureIndex({b:1, c:1})
      WriteResult({ "nInserted" : 1 })
      > mydb.test.find({c: {$regex: "", $options: "x"}})
      > mydb.test.find({c: {$regex: "", $options: "x"}}).explain()
      {
              "cursor" : "BasicCursor",
              "isMultiKey" : false,
              "n" : 0,
              "nscannedObjects" : 0,
              "nscanned" : 0,
              "nscannedObjectsAllPlans" : 0,
              "nscannedAllPlans" : 0,
              "scanAndOrder" : false,
              "indexOnly" : false,
              "nYields" : 0,
              "nChunkSkips" : 0,
              "millis" : 0,
              "indexBounds" : {
       
              },
              "server" : "localhost.localdomain:28000"
      }
      > mydb.test.dropIndexes()
      {
              "nIndexesWas" : 4,
              "msg" : "non-_id indexes dropped for collection",
              "ok" : 1
      }
      > mydb.test.ensureIndex({c:1})
      WriteResult({ "nInserted" : 1 })
      > mydb.test.find({c: {$regex: "", $options: "x"}}).explain()
      2014-03-06T17:27:41.195-0800 Error: 16863 Error converting //x in field 0 to a JS RegExp object: SyntaxError: Invalid flags supplied to RegExp constructor 'x' at src/mongo/shell/types.js:616
      > mydb.test.dropIndexes()
      {
              "nIndexesWas" : 2,
              "msg" : "non-_id indexes dropped for collection",
              "ok" : 1
      }
      > mydb.test.ensureIndex({c:1, d:1})
      WriteResult({ "nInserted" : 1 })
      > mydb.test.find({c: {$regex: "", $options: "x"}})
      > mydb.test.find({c: {$regex: "", $options: "x"}}).explain()
      2014-03-06T17:31:15.740-0800 Error: 16863 Error converting //x in field 0 to a JS RegExp object: SyntaxError: Invalid flags supplied to RegExp constructor 'x'

      Attachments

        Activity

          People

            Unassigned Unassigned
            andrew.emil@10gen.com Andrew Emil (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: