| Steps To Reproduce: |
Enable sargable rewrites.
> db.test.find()
|
{ "_id" : 0, "num" : 2, "a" : { "array" : [ ] } }
|
|
> db.adminCommand({setParameter: 1, internalQueryFrameworkControl: "forceClassicEngine"})
|
{ "was" : "trySbeEngine", "ok" : 1 }
|
> db.test.aggregate({$match: {$or: [{nonexistent: 1}, {$and: [{"a.array": {$elemMatch: {$ne: "str"}}}, {"num": {$gte: 1}}]}]}})
|
// no results
|
|
> db.adminCommand({setParameter: 1, internalQueryFrameworkControl: "tryBonsai"})
|
{ "was" : "forceClassicEngine", "ok" : 1 }
|
> db.test.aggregate({$match: {$or: [{nonexistent: 1}, {$and: [{"a.array": {$elemMatch: {$ne: "str"}}}, {"num": {$gte: 1}}]}]}})
|
{ "_id" : 0, "num" : 2, "a" : { "array" : [ ] } }
|
>
|
|