@@ -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
1313Definition
@@ -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
404443Sharded Collections
0 commit comments