We have come across a problem that was introduced with this change: SERVER-34012. The exact line causing this is https://github.com/mongodb/mongo/blame/master/src/mongo/db/matcher/expression_tree.cpp#L250.
This problem can only be seen on MongoDB v5, earlier versions work properly.
Steps to reproduce:
Create "some" collection and then run:
db.getCollection("some").aggregate({$match: { "$or" : [ { "x" : "a" }, { "x" : "b" }, { "x" : /c/ }] } })
Expected output: No failure.
Output:
uncaught exception: Error: command failed: { "ok" : 0, "errmsg" : "Failed to optimize pipeline :: caused by :: Failed to optimize expression :: caused by :: Incorrect number of non-equivalent expressions", "code" : 3401204, "codeName" : "Location3401204" } with original command request: { "aggregate" : "FileNodeVersions", "pipeline" : [ { "$match" : { "$or" : [ { "x" : "a" }, { "x" : "b" }, { "x" : /c/ } ] } } ], "cursor" : { }, "lsid" : { "id" : UUID("af1c7696-912f-4ad8-a53b-8eb9db5c0162") }
- is related to
-
SERVER-34012 Planner's logic for taking union of index bounds intervals is slow for large $or queries
- Closed