Package dev.morphia.aggregation.stages
Class Lookup
- java.lang.Object
-
- dev.morphia.aggregation.stages.Stage
-
- dev.morphia.aggregation.stages.Lookup
-
public class Lookup extends Stage
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
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Lookupas(String as)Name of the array field added to each output document.LookupforeignField(String foreignField)Specifies the field from the documents in the from collection.static Lookupfrom(Class<?> from)Deprecated, for removal: This API element is subject to removal in a future version.uselookup(Class)static Lookupfrom(String from)Deprecated, for removal: This API element is subject to removal in a future version.uselookup(String)StringgetAs()StringgetForeignField()StringgetFrom()Class<?>getFromType()StringgetLocalField()List<Stage>getPipeline()dev.morphia.aggregation.expressions.impls.DocumentExpressiongetVariables()Lookuplet(String name, dev.morphia.aggregation.expressions.impls.Expression expression)Defines a variableLookuplocalField(String localField)Specifies the field from the documents input to the $lookup stage.static Lookuplookup()Creates a new stage using the target collectionstatic Lookuplookup(Class<?> from)Creates a new stage using the target collection for the mapped typestatic Lookuplookup(String from)Creates a new stage using the target collectionLookuppipeline(Stage... stages)Specifies the pipeline to run on the joined collection.-
Methods inherited from class dev.morphia.aggregation.stages.Stage
aggregation, stageName
-
-
-
-
Method Detail
-
from
@Deprecated(forRemoval=true) public static Lookup from(Class<?> from)
Deprecated, for removal: This API element is subject to removal in a future version.uselookup(Class)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
-
from
@Deprecated(forRemoval=true) public static Lookup from(String from)
Deprecated, for removal: This API element is subject to removal in a future version.uselookup(String)Creates a new stage using the target collection- Parameters:
from- the target collection- Returns:
- the new stage
-
lookup
public static Lookup lookup(Class<?> from)
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
-
lookup
public static Lookup lookup(String from)
Creates a new stage using the target collection- Parameters:
from- the target collection- Returns:
- the new stage
- Since:
- 2.2
-
lookup
public static Lookup lookup()
Creates a new stage using the target collection- Returns:
- the new stage
- Since:
- 2.3
-
as
public Lookup as(String 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
public Lookup foreignField(String foreignField)
Specifies the field from the documents in the from collection.- Parameters:
foreignField- the field name- Returns:
- this
-
getAs
@Nullable @MorphiaInternal public String getAs()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getForeignField
@Nullable @MorphiaInternal public String getForeignField()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getFrom
@Nullable @MorphiaInternal public String getFrom()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getFromType
@Nullable @MorphiaInternal public Class<?> getFromType()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getLocalField
@Nullable @MorphiaInternal public String getLocalField()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getPipeline
@Nullable @MorphiaInternal public List<Stage> getPipeline()
- Returns:
- the embeded pipeline
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getVariables
@MorphiaInternal public dev.morphia.aggregation.expressions.impls.DocumentExpression getVariables()
- Returns:
- the embeded pipeline's variables
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
let
public Lookup let(String name, dev.morphia.aggregation.expressions.impls.Expression expression)
Defines a variable- Parameters:
name- the variable nameexpression- the variable value expression- Returns:
- this
-
localField
public Lookup localField(String localField)
Specifies the field from the documents input to the $lookup stage.- Parameters:
localField- the field name- Returns:
- this
-
pipeline
public Lookup pipeline(Stage... stages)
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
-
-