@@ -7,7 +7,7 @@ $lookup (aggregation)
7
7
.. contents:: On this page
8
8
:local:
9
9
:backlinks: none
10
- :depth: 1
10
+ :depth: 2
11
11
:class: singlecol
12
12
13
13
Definition
@@ -206,7 +206,10 @@ The :pipeline:`$lookup` stage accepts a document with these fields:
206
206
``pipeline`` ``[]``.
207
207
208
208
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`.
210
213
211
214
The ``pipeline`` cannot directly access the joined document
212
215
fields. Instead, define variables for the joined document fields
@@ -332,7 +335,10 @@ The :pipeline:`$lookup` accepts a document with these fields:
332
335
return all documents, specify an empty ``pipeline`` ``[]``.
333
336
334
337
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`.
336
342
337
343
The ``pipeline`` cannot directly access the document fields.
338
344
Instead, define variables for the document fields using the
@@ -399,6 +405,39 @@ the ``pipeline`` field.
399
405
}
400
406
}
401
407
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
+
402
441
.. _lookup-sharded-collections:
403
442
404
443
Sharded Collections
0 commit comments