I have a simple collection with these values:
{ "_id" : ObjectId("538602b59b6fe0b5efcf8c13"), "domainId" : "type" } { "_id" : ObjectId("538602b59b6fe0b5efcf8c14"), "domainId" : "view" } { "_id" : ObjectId("538602b59b6fe0b5efcf8c15"), "domainId" : "vfsdata", "namespace" : "eportal" } { "_id" : ObjectId("538602b59b6fe0b5efcf8c16"), "domainId" : "admin", "namespace" : "eportal" }
As expected the query
"$or" : [ { "namespace" : "eportal"} , { "namespace" : null }]
found all documents in the collection.
If i add a unique compound index for the fields namespace and eportal, the same query found only the documents, where the field namespace exists.
In version 2.4 of MongoDB the second query found as expected all documents.
- duplicates
-
SERVER-13960 Queries containing $or may miss results if multiple clauses use the same index
- Closed