-
Type:
Bug
-
Resolution: Won't Fix
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
-
ALL
Steps to reproduce:
> db.c.insert({_id: 1, a: "foo"}) > db.c.createIndex({a: 1}) > db.c.find({a: "foo"}, {key: {$meta: "indexKey"}}) [ { _id: 1, a: 'foo', key: { a: 'foo' } } ] > db.c.find({_id: 1}, {key: {$meta: "indexKey"}}) [ { _id: 1, a: 'foo' } ]
I would have expected:
> db.c.find({_id: 1}, {key: {$meta: "indexKey"}}) [ { _id: 1, a: 'foo', key: { _id: 1 } } ]
> db.c.find({_id: 1}, {key: {$meta: "indexKey"}}).explain().queryPlanner { namespace: 'test.c', indexFilterSet: false, parsedQuery: { _id: { '$eq': 1 } }, queryHash: '58F0F49D', planCacheKey: '0028A5F4', maxIndexedOrSolutionsReached: false, maxIndexedAndSolutionsReached: false, maxScansToExplodeReached: false, winningPlan: { stage: 'PROJECTION_DEFAULT', transformBy: { key: { '$meta': 'indexKey' } }, inputStage: { stage: 'IDHACK' } }, rejectedPlans: [] }
One theory is that IDHACK is not setting the metadata field properly, but this requires further investigation.