|
After dicussing with cross@mongodb.com, looks like this is working as designed. The replica set in question has the following indices:
shard01:PRIMARY> db.foo.getIndexes()
|
[
|
{
|
"v" : 1,
|
"key" : {
|
"_id" : 1
|
},
|
"name" : "_id_",
|
"ns" : "test.foo"
|
},
|
{
|
"v" : 1,
|
"key" : {
|
"a" : 1
|
},
|
"name" : "a_1",
|
"ns" : "test.foo"
|
},
|
{
|
"v" : 1,
|
"key" : {
|
"b" : 1
|
},
|
"name" : "b_1",
|
"ns" : "test.foo"
|
},
|
{
|
"v" : 1,
|
"key" : {
|
"c" : 1
|
},
|
"name" : "c_1",
|
"ns" : "test.foo"
|
},
|
{
|
"v" : 1,
|
"key" : {
|
"d" : 1
|
},
|
"name" : "d_1",
|
"ns" : "test.foo"
|
},
|
{
|
"v" : 1,
|
"key" : {
|
"e" : 1,
|
"sparse" : true
|
},
|
"name" : "e_1_sparse_true",
|
"ns" : "test.foo"
|
}
|
]
|
Note that there is no index with the key pattern {e: 1}. Instead, there is an index with key pattern {e: 1, sparse: 1}. Therefore, hinting on {e: 1} was indeed a bad hint! Looks like this was caused by a subtle typo:
t.ensureIndex({e: 1, sparse: true}); // typo!
|
t.ensureIndex({e: 1}, {sparse: true}); // correct
|
|