summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Tuckman <ted.tuckman@mongodb.com>2021-09-02 10:02:49 -0400
committerTed Tuckman <ted.tuckman@mongodb.com>2021-09-02 17:45:52 -0400
commit057ee3d434a3822bc007d7a34524b4eb0a1aa1ea (patch)
tree8c6bd2deaba1428a499d03e35e7a4af828d44233
parent8b833e28d63c26c33517ef9cfdd53f06e7c5e05c (diff)
downloadmongo-057ee3d434a3822bc007d7a34524b4eb0a1aa1ea.tar.gz
SERVER-59743 Set SEARCH_META in $unionWith subpipeline
(cherry-picked from commit 2b0d538db8c0c9b9d7992d4489ba7171c721dfb7) (cherry-picked from commit a7a458ee9a78a3834c7a7f081dcd8bc73f2d0f21)
-rw-r--r--src/mongo/db/pipeline/document_source_union_with.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/document_source_union_with.cpp b/src/mongo/db/pipeline/document_source_union_with.cpp
index e52540f5e58..b232f7f998e 100644
--- a/src/mongo/db/pipeline/document_source_union_with.cpp
+++ b/src/mongo/db/pipeline/document_source_union_with.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/pipeline/document_source_single_document_transformation.h"
#include "mongo/db/pipeline/document_source_union_with.h"
#include "mongo/db/pipeline/document_source_union_with_gen.h"
+#include "mongo/db/query/query_knobs_gen.h"
#include "mongo/db/views/resolved_view.h"
#include "mongo/logv2/log.h"
@@ -211,6 +212,15 @@ DocumentSource::GetNextResult DocumentSourceUnionWith::doGetNext() {
1,
"$unionWith attaching cursor to pipeline {pipeline}",
"pipeline"_attr = serializedPipe);
+ // $$SEARCH_META can be set during runtime earlier in the pipeline, and therefore must be
+ // copied to the subpipeline manually.
+ if (enableSearchMeta.load()) {
+ auto metaVal = pExpCtx->variables.getValue(Variables::kSearchMetaId, Document());
+ if (!metaVal.missing()) {
+ _pipeline->getContext()->variables.setReservedValue(
+ Variables::kSearchMetaId, std::move(metaVal), true);
+ }
+ }
try {
_pipeline =
pExpCtx->mongoProcessInterface->attachCursorSourceToPipeline(_pipeline.release());