Package dev.morphia.aggregation.stages
Class Lookup
java.lang.Object
dev.morphia.aggregation.stages.Stage
dev.morphia.aggregation.stages.Lookup
Performs a left outer join to an unsharded collection in the same database to filter in documents from the “joined” collection for
processing. To each input document, the $lookup stage adds a new array field whose elements are the matching documents from the
“joined” collection. The $lookup stage passes these reshaped documents to the next stage.
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionName of the array field added to each output document.foreignField
(String foreignField) Specifies the field from the documents in the from collection.Defines a variablelocalField
(String localField) Specifies the field from the documents input to the $lookup stage.static Lookup
lookup()
Creates a new stage using the target collectionstatic Lookup
Creates a new stage using the target collection for the mapped typestatic Lookup
Creates a new stage using the target collectionSpecifies the pipeline to run on the joined collection.
-
Method Details
-
lookup
Creates a new stage using the target collection for the mapped type- Parameters:
from
- the type to use for determining the target collection- Returns:
- the new stage
- Since:
- 2.2
- MongoDB documentation
- Aggregration Pipeline Stage: $lookup
- Since server release
- 3.6
-
lookup
Creates a new stage using the target collection- Parameters:
from
- the target collection- Returns:
- the new stage
- Since:
- 2.2
- MongoDB documentation
- Aggregration Pipeline Stage: $lookup
- Since server release
- 3.6
-
lookup
Creates a new stage using the target collection- Returns:
- the new stage
- Since:
- 2.3
- MongoDB documentation
- Aggregration Pipeline Stage: $lookup
- Since server release
- 3.6
-
as
Name of the array field added to each output document. Contains the documents traversed in the $graphLookup stage to reach the document.- Parameters:
as
- the name- Returns:
- this
-
foreignField
Specifies the field from the documents in the from collection.- Parameters:
foreignField
- the field name- Returns:
- this
-
let
Defines a variable- Parameters:
name
- the variable nameexpression
- the variable value expression- Returns:
- this
-
localField
Specifies the field from the documents input to the $lookup stage.- Parameters:
localField
- the field name- Returns:
- this
-
pipeline
Specifies the pipeline to run on the joined collection. The pipeline determines the resulting documents from the joined collection. To return all documents, specify an empty pipeline.The pipeline cannot include the $out stage or the $merge stage.
- Parameters:
stages
- the stages of the embedded pipeline- Returns:
- this
- Since:
- 2.2
-