| Steps To Reproduce: |
> db.foo.find()
|
{ "_id" : { "x" : 1, "y" : 1 } }
|
> db.foo.find({}, {"_id.x": 1})
|
{ "_id" : { "x" : 1, "y" : 1 } }
|
> db.foo.find({"_id.x": 1}, {_id: 0, "_id.x": 1}) // This projection doesn't really make sense, but is accepted by the server.
|
{ } // Entire _id excluded.
|
> db.foo.ensureIndex({"_id.x": 1})
|
{
|
"createdCollectionAutomatically" : false,
|
"numIndexesBefore" : 1,
|
"numIndexesAfter" : 2,
|
"ok" : 1
|
}
|
> db.foo.find({"_id.x": 1}, {_id: 0, "_id.x": 1})
|
{ "_id" : { "x" : 1 } } // A covered query allows only the 'x' subfield to be included.
|
> db.foo.explain().find({"_id.x": 1}, {_id: 0, "_id.x": 1})
|
{
|
"queryPlanner" : {
|
"plannerVersion" : 1,
|
"namespace" : "test.foo",
|
"indexFilterSet" : false,
|
"parsedQuery" : {
|
"_id.x" : {
|
"$eq" : 1
|
}
|
},
|
"winningPlan" : {
|
"stage" : "PROJECTION",
|
"transformBy" : {
|
"_id" : 0,
|
"_id.x" : 1
|
},
|
"inputStage" : {
|
"stage" : "IXSCAN",
|
"keyPattern" : {
|
"_id.x" : 1
|
},
|
"indexName" : "_id.x_1",
|
"isMultiKey" : false,
|
"multiKeyPaths" : {
|
"_id.x" : [ ]
|
},
|
"isUnique" : false,
|
"isSparse" : false,
|
"isPartial" : false,
|
"indexVersion" : 2,
|
"direction" : "forward",
|
"indexBounds" : {
|
"_id.x" : [
|
"[1.0, 1.0]"
|
]
|
}
|
}
|
},
|
"rejectedPlans" : [ ]
|
},
|
"serverInfo" : {
|
"host" : "franklinia",
|
"port" : 27017,
|
"version" : "0.0.0",
|
"gitVersion" : "unknown"
|
},
|
"ok" : 1
|
}
|
|