|
This problem has been fixed as of version 4.2 for regular indexes:
MongoDB Enterprise > db.c.drop()
|
true
|
MongoDB Enterprise > db.c.insert({a: 1})
|
WriteResult({ "nInserted" : 1 })
|
MongoDB Enterprise > db.c.drop()
|
true
|
MongoDB Enterprise > db.c.insert({})
|
WriteResult({ "nInserted" : 1 })
|
MongoDB Enterprise > db.c.insert({a: null})
|
WriteResult({ "nInserted" : 1 })
|
MongoDB Enterprise > db.c.insert({a: undefined})
|
WriteResult({ "nInserted" : 1 })
|
MongoDB Enterprise > db.c.find({a: {$eq: null}})
|
{ "_id" : ObjectId("5d3b57d42994c7ff8f5dffa5") }
|
{ "_id" : ObjectId("5d3b57d72994c7ff8f5dffa6"), "a" : null }
|
{ "_id" : ObjectId("5d3b57da2994c7ff8f5dffa7"), "a" : undefined }
|
MongoDB Enterprise > db.c.createIndex({a: 1})
|
{
|
"createdCollectionAutomatically" : false,
|
"numIndexesBefore" : 1,
|
"numIndexesAfter" : 2,
|
"commitQuorum" : 1,
|
"ok" : 1
|
}
|
MongoDB Enterprise > db.c.find({a: {$eq: null}})
|
{ "_id" : ObjectId("5d3b57da2994c7ff8f5dffa7"), "a" : undefined }
|
{ "_id" : ObjectId("5d3b57d42994c7ff8f5dffa5") }
|
{ "_id" : ObjectId("5d3b57d72994c7ff8f5dffa6"), "a" : null }
|
MongoDB Enterprise > db.c.find({a: {$eq: null}}).explain()
|
{
|
"queryPlanner" : {
|
"plannerVersion" : 1,
|
"namespace" : "test.c",
|
"indexFilterSet" : false,
|
"parsedQuery" : {
|
"a" : {
|
"$eq" : null
|
}
|
},
|
"queryHash" : "4B53BE76",
|
"planCacheKey" : "100FCEBA",
|
"winningPlan" : {
|
"stage" : "FETCH",
|
"filter" : {
|
"a" : {
|
"$eq" : null
|
}
|
},
|
"inputStage" : {
|
"stage" : "IXSCAN",
|
"keyPattern" : {
|
"a" : 1
|
},
|
"indexName" : "a_1",
|
"isMultiKey" : false,
|
"multiKeyPaths" : {
|
"a" : [ ]
|
},
|
"isUnique" : false,
|
"isSparse" : false,
|
"isPartial" : false,
|
"indexVersion" : 2,
|
"direction" : "forward",
|
"indexBounds" : {
|
"a" : [
|
"[undefined, undefined]",
|
"[null, null]"
|
]
|
}
|
}
|
},
|
"rejectedPlans" : [ ]
|
},
|
"serverInfo" : {
|
"host" : "storchbox",
|
"port" : 27017,
|
"version" : "0.0.0",
|
"gitVersion" : "unknown"
|
},
|
"ok" : 1
|
}
|
However, the related problem specifically for "text" indexes still exists. I'm repurposing this ticket to track specifically the "text" index problem.
|
|
This same problem exists for equality to null predicates over the prefix of a text index:
> db.c.drop();
|
> db.c.ensureIndex({a: 1, b: "text"});
|
> db.c.insert({a: undefined, b: "lorem ipsum"});
|
> db.c.find({a: null, $text: {$search: "lorem"}});
|
// Should return one result, but returns nothing.
|
This is significant because the planning code is separate for text indexes and may require a separate fix.
|