diff options
-rw-r--r-- | src/mongo/db/query/get_executor.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp index c4536c8b654..a756bb5c4eb 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -209,11 +209,19 @@ IndexEntry indexEntryFromIndexCatalogEntry(OperationContext* opCtx, if (canonicalQuery) { stdx::unordered_set<std::string> fields; QueryPlannerIXSelect::getFields(canonicalQuery->root(), &fields); - const auto projectedFields = projection_executor_utils::applyProjectionToFields( + auto projectedFields = projection_executor_utils::applyProjectionToFields( wildcardProjection->exec(), fields); - multikeyPathSet = - getWildcardMultikeyPathSet(wam, opCtx, projectedFields, &mkAccessStats); + // For a compound wildcard index, we also want to get the multikey information + // for (non-wildcard) fields in the index which are being queried. + auto indexKeys = wam->getKeyPattern().getFieldNames<std::set<std::string>>(); + std::set_intersection(fields.begin(), + fields.end(), + indexKeys.begin(), + indexKeys.end(), + std::inserter(projectedFields, projectedFields.begin())); + + multikeyPathSet = getWildcardMultikeyPathSet(wam, opCtx, fields, &mkAccessStats); } else { multikeyPathSet = getWildcardMultikeyPathSet(wam, opCtx, &mkAccessStats); } |