Skip to content

Commit a430aeb

Browse files
DOCSP-15298 doc search as subpipeline of lookup and unionWith (#1177)
* DOCSP-15298 doc search as subpipeline of lookup and unionWith * DOCSP-15298 updates for CR feedback * DOCSP-15298 updates to increase depth of toc
1 parent 0079bce commit a430aeb

File tree

2 files changed

+74
-5
lines changed

2 files changed

+74
-5
lines changed

source/reference/operator/aggregation/lookup.txt

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $lookup (aggregation)
77
.. contents:: On this page
88
:local:
99
:backlinks: none
10-
:depth: 1
10+
:depth: 2
1111
:class: singlecol
1212

1313
Definition
@@ -206,7 +206,10 @@ The :pipeline:`$lookup` stage accepts a document with these fields:
206206
``pipeline`` ``[]``.
207207

208208
The ``pipeline`` cannot include the :pipeline:`$out` stage or the
209-
:pipeline:`$merge` stage.
209+
:pipeline:`$merge` stage. Starting in v6.0, the ``pipeline``
210+
can contain the :atlas:`Atlas Search </atlas-search>`
211+
:pipeline:`$search` stage as the first stage inside the
212+
pipeline. To learn more, see :ref:`fts-lookup-behavior`.
210213

211214
The ``pipeline`` cannot directly access the joined document
212215
fields. Instead, define variables for the joined document fields
@@ -332,7 +335,10 @@ The :pipeline:`$lookup` accepts a document with these fields:
332335
return all documents, specify an empty ``pipeline`` ``[]``.
333336

334337
The ``pipeline`` cannot include the :pipeline:`$out` or
335-
:pipeline:`$merge` stages.
338+
:pipeline:`$merge` stages. Starting in v6.0, the ``pipeline``
339+
can contain the :atlas:`Atlas Search </atlas-search>`
340+
:pipeline:`$search` stage as the first stage inside the
341+
pipeline. To learn more, see :ref:`fts-lookup-behavior`.
336342

337343
The ``pipeline`` cannot directly access the document fields.
338344
Instead, define variables for the document fields using the
@@ -399,6 +405,39 @@ the ``pipeline`` field.
399405
}
400406
}
401407

408+
.. _fts-lookup-behavior:
409+
410+
Atlas Search Support
411+
~~~~~~~~~~~~~~~~~~~~
412+
413+
Starting in v6.0, the ``pipeline`` can contain the :atlas:`Atlas Search
414+
</atlas-search>` :pipeline:`$search` stage as the first stage inside
415+
the pipeline.
416+
417+
For example, when you :ref:`lookup-syntax-let-pipeline` or run
418+
:ref:`lookup-syntax-concise-correlated-subquery`, you can specify
419+
:pipeline:`$search` inside the pipeline as shown below:
420+
421+
.. code-block::
422+
:copyable: false
423+
:emphasize-lines: 7-11
424+
425+
[{
426+
"$lookup": {
427+
"from": <joined collection>,
428+
"let": {<var_n>: <expression>, ...},
429+
"as": <output array field>,
430+
"pipeline": [{
431+
"$search": {
432+
"<operator>": {
433+
<operator-specification>
434+
}
435+
},
436+
...
437+
}]
438+
}
439+
}]
440+
402441
.. _lookup-sharded-collections:
403442

404443
Sharded Collections

source/reference/operator/aggregation/unionWith.txt

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $unionWith (aggregation)
77
.. contents:: On this page
88
:local:
99
:backlinks: none
10-
:depth: 1
10+
:depth: 2
1111
:class: singlecol
1212

1313
Definition
@@ -69,7 +69,10 @@ fields:
6969
``[ <stage1>, <stage2>, ...]``
7070

7171
The pipeline cannot include the :pipeline:`$out` and
72-
:pipeline:`$merge` stages.
72+
:pipeline:`$merge` stages. Starting in v6.0, the ``pipeline``
73+
can contain the :atlas:`Atlas Search </atlas-search>`
74+
:pipeline:`$search` stage as the first stage inside the pipeline.
75+
To learn more, see :ref:`fts-unionwith-behavior`.
7376

7477
The :pipeline:`$unionWith` operation would correspond to the following
7578
SQL statement:
@@ -204,6 +207,33 @@ top-level collection/view on which the
204207
</core/views>`, then its collation must match that of the top-level
205208
collection/view. Otherwise, the operation errors.
206209

210+
.. _fts-unionwith-behavior:
211+
212+
Atlas Search Support
213+
~~~~~~~~~~~~~~~~~~~~
214+
215+
Starting in v6.0, the ``pipeline`` can contain the :atlas:`Atlas Search
216+
</atlas-search>` :pipeline:`$search` stage as the first stage inside
217+
the pipeline.
218+
219+
.. code-block::
220+
:copyable: false
221+
:emphasize-lines: 5-9
222+
223+
[{
224+
"$lookup": {
225+
"coll": <collection-name>,
226+
"pipeline": [{
227+
"$search": {
228+
"<operator>": {
229+
<operator-specification>
230+
}
231+
},
232+
...
233+
}]
234+
}
235+
}]
236+
207237
Restrictions
208238
~~~~~~~~~~~~
209239

0 commit comments

Comments
 (0)