The collection index has an index on the val field.
> db.index.find({val: {$not: {$gte: null}}}) > db.non.find({val: {$not: {$gte: null}}}) { "_id" : ObjectId("5f16f0bb1fe2fb0ca7b13d12"), "val" : [ ] } > db.index.find() { "_id" : ObjectId("5f16f0da1fe2fb0ca7b13d13"), "val" : [ ] } { "_id" : ObjectId("5f16ff661fe2fb0ca7b13d14"), "val" : null } > db.non.find() { "_id" : ObjectId("5f16f0bb1fe2fb0ca7b13d12"), "val" : [ ] } { "_id" : ObjectId("5f16ff6d1fe2fb0ca7b13d15"), "val" : null } > db.index.getIndexes() [ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" }, { "v" : 2, "key" : { "val" : 1 }, "name" : "val_1" } ] > db.non.getIndexes() [ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" } ]
The problem is probably in this function complement, called from here
- depends on
-
SERVER-47382 Enable $not with arrays
- Closed
- is related to
-
SERVER-45233 Indexed inequalities to arrays return incorrect results
- Closed
- related to
-
SERVER-56468 Incorrect plan cache entry for {$ne: null} predicate, leads to missing query results
- Closed
-
SERVER-51351 Complete TODO listed in SERVER-49766
- Closed