summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHana Pearlman <hana.pearlman@mongodb.com>2021-04-16 13:43:02 +0000
committerHana Pearlman <hana.pearlman@mongodb.com>2021-04-16 14:12:15 +0000
commit9193a7d1fb2d8a916e310c708c0d68e2c7c1eb53 (patch)
treef39b4d2ae31a08b3266be54f287880492c1bce4f
parent2f99cbab75fa49374365ab29647661bd609f905e (diff)
downloadmongo-9193a7d1fb2d8a916e310c708c0d68e2c7c1eb53.tar.gz
Get multikey info for all wildcard index fields being queried
-rw-r--r--src/mongo/db/query/get_executor.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index c4536c8b654..36179df5791 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -209,9 +209,18 @@ 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);
+ // 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, projectedFields, &mkAccessStats);
} else {