-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.0.0
-
Component/s: Index Maintenance
-
None
-
Environment:Any, git hash 644df81d2167628a7a9494a1953f981d148ebfbb
If you create a multi-key index that has documents omitted because they have null values or empty arrays, mongo may return incorrect results on other queries that attempt to use part of that index. The query planner will use a multi-key index (take, for example, an index with keys: k0, k1) if you run a query that matches part of the index (for example, searching on k0). However, if some documents are missing because criteria unrelated to the current query causes them to be excluded from the index (for example, where k1 is an array, and the document has an empty array), then searching just on the partial index will not return all documents that should have matched.
Repro follows:
MongoDB shell version: 1.1.0-
url: testdb
connecting to: 127.0.0.1:27001/testdb
type "help" for help
> db.party.save(
);
> db.party.save(
);
> db.party.find(
);
{"_id" : ObjectId( "4aa09b10fce2291061418fb1") , "id" : 1 , "info" : [] , "str" : "hi"} {"_id" : ObjectId( "4aa09b1bfce2291061418fb2") , "id" : 1 , "info" : ["foo"] , "str" : "hi"}> db.party.ensureIndex(
{id:1,info:1});
true
> db.party.find(
);
{"_id" : ObjectId( "4aa09b1bfce2291061418fb2") , "id" : 1 , "info" : ["foo"] , "str" : "hi"}> db.party.dropIndexes();
{"nIndexesWas" : 2 , "msg" : "all indexes deleted for collection" , "ok" : 1}> db.party.ensureIndex(
{id:1});
true
> db.party.find(
);
{"_id" : ObjectId( "4aa09b10fce2291061418fb1") , "id" : 1 , "info" : [] , "str" : "hi"} {"_id" : ObjectId( "4aa09b1bfce2291061418fb2") , "id" : 1 , "info" : ["foo"] , "str" : "hi"}- depends on
-
SERVER-146 arrays don't match themselves
- Closed