Skip to content

Commit f425a69

Browse files
authored
DOCSP-49303-update-lookup-language (#11769)
* DOCSP-49303-update-lookup-language * fix * last edit
1 parent ab0a465 commit f425a69

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

source/includes/fact-sbe-lookup-overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ query engine <sbe-landing>` to execute :pipeline:`$lookup` stages
33
if *all* preceding stages in the pipeline can also be executed by the
44
|sbe-short| and none of the following conditions are true:
55

6-
- The ``$lookup`` operation executes a pipeline on a joined collection.
6+
- The ``$lookup`` operation executes a pipeline on a foreign collection.
77
To see an example of this kind of operation, see
88
:ref:`lookup-syntax-let-pipeline`.
99

source/reference/operator/aggregation/lookup.txt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $lookup (aggregation)
66

77
.. meta::
88
:keywords: atlas
9-
:description: Learn about the $lookup aggregation stage, which performs a left outer join to a collection in the same database, and filters in documents from the "joined" collection for processing.
9+
:description: Learn about the $lookup aggregation stage, which performs a left outer join to a collection in the same database, and filters in documents from the foreign collection for processing.
1010

1111
.. contents:: On this page
1212
:local:
@@ -22,10 +22,10 @@ Definition
2222
.. versionchanged:: 8.0
2323

2424
Performs a left outer join to a collection in the *same* database to
25-
filter in documents from the "joined" collection for processing. The
25+
filter in documents from the foreign collection for processing. The
2626
:pipeline:`$lookup` stage adds a new array field to each input
2727
document. The new array field contains the matching documents from
28-
the "joined" collection. The :pipeline:`$lookup` stage passes these
28+
the foreign collection. The :pipeline:`$lookup` stage passes these
2929
reshaped documents to the next stage.
3030

3131
Starting in MongoDB 5.1, you can use :pipeline:`$lookup` with sharded
@@ -64,7 +64,7 @@ The :pipeline:`$lookup` accepts a document with these fields:
6464

6565
.. list-table::
6666
:header-rows: 1
67-
:widths: 15 15 70
67+
:widths: 20 20 80
6868

6969
* - Field
7070
- Necessity
@@ -163,7 +163,7 @@ Equality Match with a Single Join Condition
163163
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
164164

165165
To perform an equality match between a field from the input documents
166-
with a field from the documents of the "joined" collection, the
166+
with a field from the documents of the foreign collection, the
167167
:pipeline:`$lookup` stage has this syntax:
168168

169169
.. code-block:: none
@@ -210,12 +210,12 @@ For MongoDB examples, see these pages:
210210

211211
.. _lookup-syntax-let-pipeline:
212212

213-
Join Conditions and Subqueries on a Joined Collection
214-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
213+
Join Conditions and Subqueries on a Foreign Collection
214+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215215

216216
MongoDB supports:
217217

218-
- Executing a pipeline on a joined collection.
218+
- Executing a pipeline on a foreign collection.
219219

220220
- Multiple join conditions.
221221

@@ -248,9 +248,9 @@ this :pipeline:`$lookup` syntax:
248248
{
249249
$lookup:
250250
{
251-
from: <joined collection>,
251+
from: <foreign collection>,
252252
let: { <var_1>: <expression>, …, <var_n>: <expression> },
253-
pipeline: [ <pipeline to run on joined collection> ],
253+
pipeline: [ <pipeline to run on foreign collection> ],
254254
as: <output array field>
255255
}
256256
}
@@ -281,8 +281,8 @@ Correlated Subqueries Using Concise Syntax
281281
.. versionadded:: 5.0
282282

283283
Starting in MongoDB 5.0, you can use a concise syntax for a correlated
284-
subquery. Correlated subqueries reference document fields from a joined
285-
"foreign" collection *and* the "local" collection on which the
284+
subquery. Correlated subqueries reference document fields from a foreign
285+
collection *and* the "local" collection on which the
286286
:method:`~db.collection.aggregate()` method was run.
287287

288288
The following new concise syntax removes the requirement for an equality
@@ -358,7 +358,7 @@ Restrictions
358358

359359
You cannot include the :pipeline:`$out` or the :pipeline:`$merge`
360360
stage in the :pipeline:`$lookup` stage. That is, when specifying a
361-
:ref:`pipeline for the joined collection
361+
:ref:`pipeline for the foreign collection
362362
<lookup-syntax-let-pipeline>`, you cannot include either stage in
363363
the ``pipeline`` field.
364364

@@ -370,7 +370,7 @@ the ``pipeline`` field.
370370
{
371371
from: <collection to join>,
372372
let: { <var_1>: <expression>, …, <var_n>: <expression> },
373-
pipeline: [ <pipeline to execute on the joined collection> ], // Cannot include $out or $merge
373+
pipeline: [ <pipeline to execute on the foreign collection> ], // Cannot include $out or $merge
374374
as: <output array field>
375375
}
376376
}
@@ -402,7 +402,7 @@ shown below:
402402

403403
[{
404404
"$lookup": {
405-
"from": <joined collection>,
405+
"from": <foreign collection>,
406406
localField: <field from the input documents>,
407407
foreignField: <field from the documents of the "from" collection>,
408408
"as": <output array field>,
@@ -426,7 +426,7 @@ shown below:
426426

427427
[{
428428
"$lookup": {
429-
"from": <joined collection>,
429+
"from": <foreign collection>,
430430
localField: <field from the input documents>,
431431
foreignField: <field from the documents of the "from" collection>,
432432
"as": <output array field>,
@@ -668,12 +668,12 @@ Create another collection ``members`` with these documents:
668668
.. code-block:: javascript
669669

670670
db.members.insertMany( [
671-
{ _id: 1, name: "artie", joined: new Date("2016-05-01"), status: "A" },
672-
{ _id: 2, name: "giraffe", joined: new Date("2017-05-01"), status: "D" },
673-
{ _id: 3, name: "giraffe1", joined: new Date("2017-10-01"), status: "A" },
674-
{ _id: 4, name: "panda", joined: new Date("2018-10-11"), status: "A" },
675-
{ _id: 5, name: "pandabear", joined: new Date("2018-12-01"), status: "A" },
676-
{ _id: 6, name: "giraffe2", joined: new Date("2018-12-01"), status: "D" }
671+
{ _id: 1, name: "artie", foreign: new Date("2016-05-01"), status: "A" },
672+
{ _id: 2, name: "giraffe", foreign: new Date("2017-05-01"), status: "D" },
673+
{ _id: 3, name: "giraffe1", foreign: new Date("2017-10-01"), status: "A" },
674+
{ _id: 4, name: "panda", foreign: new Date("2018-10-11"), status: "A" },
675+
{ _id: 5, name: "pandabear", foreign: new Date("2018-12-01"), status: "A" },
676+
{ _id: 6, name: "giraffe2", foreign: new Date("2018-12-01"), status: "D" }
677677
] )
678678

679679
The following aggregation operation joins documents in the ``classes``
@@ -704,9 +704,9 @@ The operation returns the following:
704704
"enrollmentlist" : [ "giraffe2", "pandabear", "artie" ],
705705
"days" : [ "M", "W", "F" ],
706706
"enrollee_info" : [
707-
{ "_id" : 1, "name" : "artie", "joined" : ISODate("2016-05-01T00:00:00Z"), "status" : "A" },
708-
{ "_id" : 5, "name" : "pandabear", "joined" : ISODate("2018-12-01T00:00:00Z"), "status" : "A" },
709-
{ "_id" : 6, "name" : "giraffe2", "joined" : ISODate("2018-12-01T00:00:00Z"), "status" : "D" }
707+
{ "_id" : 1, "name" : "artie", "foreign" : ISODate("2016-05-01T00:00:00Z"), "status" : "A" },
708+
{ "_id" : 5, "name" : "pandabear", "foreign" : ISODate("2018-12-01T00:00:00Z"), "status" : "A" },
709+
{ "_id" : 6, "name" : "giraffe2", "foreign" : ISODate("2018-12-01T00:00:00Z"), "status" : "D" }
710710
]
711711
}
712712
{
@@ -715,8 +715,8 @@ The operation returns the following:
715715
"enrollmentlist" : [ "giraffe1", "artie" ],
716716
"days" : [ "T", "F" ],
717717
"enrollee_info" : [
718-
{ "_id" : 1, "name" : "artie", "joined" : ISODate("2016-05-01T00:00:00Z"), "status" : "A" },
719-
{ "_id" : 3, "name" : "giraffe1", "joined" : ISODate("2017-10-01T00:00:00Z"), "status" : "A" }
718+
{ "_id" : 1, "name" : "artie", "foreign" : ISODate("2016-05-01T00:00:00Z"), "status" : "A" },
719+
{ "_id" : 3, "name" : "giraffe1", "foreign" : ISODate("2017-10-01T00:00:00Z"), "status" : "A" }
720720
]
721721
}
722722

@@ -750,7 +750,7 @@ Create another collection ``items`` with these documents:
750750
The following operation first uses the :pipeline:`$lookup` stage to
751751
join the two collections by the ``item`` fields and then uses
752752
:expression:`$mergeObjects` in the :pipeline:`$replaceRoot` to merge
753-
the joined documents from ``items`` and ``orders``:
753+
the foreign documents from ``items`` and ``orders``:
754754

755755
.. code-block:: javascript
756756

@@ -795,13 +795,13 @@ The operation returns these documents:
795795
Use Multiple Join Conditions and a Correlated Subquery
796796
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
797797

798-
Pipelines can execute on a joined collection and include multiple join
798+
Pipelines can execute on a foreign collection and include multiple join
799799
conditions. The :query:`$expr` operator enables more complex join
800800
conditions including conjunctions and non-equality matches.
801801

802802
A join condition can reference a field in the local collection on which
803803
the :method:`~db.collection.aggregate()` method was run and reference a
804-
field in the joined collection. This allows a correlated subquery
804+
field in the foreign collection. This allows a correlated subquery
805805
between the two collections.
806806

807807
MongoDB 5.0 supports :ref:`concise correlated subqueries
@@ -926,8 +926,8 @@ Perform an Uncorrelated Subquery with ``$lookup``
926926
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
927927

928928
An aggregation pipeline :pipeline:`$lookup` stage can execute a pipeline
929-
on the joined collection, which allows uncorrelated subqueries. An
930-
uncorrelated subquery does not reference the joined document fields.
929+
on the foreign collection, which allows uncorrelated subqueries. An
930+
uncorrelated subquery does not reference the local document fields.
931931

932932
.. note::
933933

@@ -1113,7 +1113,7 @@ The following example:
11131113

11141114
There is a match for the ``soda`` value in the ``orders.drink`` and
11151115
``restaurants.beverages`` fields. This output shows the ``matches``
1116-
array and contains all joined fields from the ``restaurants`` collection
1116+
array and contains all foreign fields from the ``restaurants`` collection
11171117
for the match:
11181118

11191119
.. code-block:: javascript

0 commit comments

Comments
 (0)