summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/pipeline.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/pipeline.cpp')
-rw-r--r--src/mongo/db/pipeline/pipeline.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mongo/db/pipeline/pipeline.cpp b/src/mongo/db/pipeline/pipeline.cpp
index 156450b961f..f3fc921a6ee 100644
--- a/src/mongo/db/pipeline/pipeline.cpp
+++ b/src/mongo/db/pipeline/pipeline.cpp
@@ -537,13 +537,14 @@ DepsTracker Pipeline::getDependencies(QueryMetadataBitSet unavailableMetadata) c
deps.needWholeDocument = true; // don't know all fields we need
if (!unavailableMetadata[DocumentMetadataFields::kTextScore]) {
- // If there is a text score, assume we need to keep it if we can't prove we don't. If we are
- // the first half of a pipeline which has been split, future stages might need it.
- if (!knowAllMeta) {
+ // There is a text score available. If we are the first half of a split pipeline, then we
+ // have to assume future stages might depend on the textScore (unless we've encountered a
+ // stage that doesn't preserve metadata).
+ if (getContext()->needsMerge && !knowAllMeta) {
deps.setNeedsMetadata(DocumentMetadataFields::kTextScore, true);
}
} else {
- // If there is no text score available, then we don't need to ask for it.
+ // There is no text score available, so we don't need to ask for it.
deps.setNeedsMetadata(DocumentMetadataFields::kTextScore, false);
}