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 Details

    • 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
      MongoDB documentation
      Aggregration Pipeline Stage: $lookup
      Since server release
      3.6
    • 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
      MongoDB documentation
      Aggregration Pipeline Stage: $lookup
      Since server release
      3.6
    • lookup

      public static Lookup 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

      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
    • let

      public Lookup let(String name, Object expression)
      Defines a variable
      Parameters:
      name - the variable name
      expression - 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