[SERVER-13086] Regex with "x" option explain fails with index on target field in 2.4 Created: 07/Mar/14  Updated: 10/Dec/14  Resolved: 21/Apr/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.4.9
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Andrew Emil (Inactive) Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-11771 extended options for $regex cannot be... Closed
Related
Operating System: ALL
Participants:

 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'



 Comments   
Comment by Andrew Emil (Inactive) [ 07/Mar/14 ]

Also effects the "s" option

Generated at Thu Feb 08 03:30:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.