Class GraphLookup

java.lang.Object
dev.morphia.aggregation.stages.Stage
dev.morphia.aggregation.stages.GraphLookup

public class GraphLookup extends Stage
Performs a recursive search on a collection, with options for restricting the search by recursion depth and query filter.
  • Method Details

    • graphLookup

      public static GraphLookup graphLookup(String from)
      Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField.
      Parameters:
      from - the target collection name
      Returns:
      this
      Since:
      2.2
      MongoDB documentation
      Aggregration Pipeline Stage: $graphLookup
    • graphLookup

      public static GraphLookup graphLookup(Class<?> from)
      Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField.
      Parameters:
      from - the target collection name
      Returns:
      this
      Since:
      2.2
      MongoDB documentation
      Aggregration Pipeline Stage: $graphLookup
    • as

      public GraphLookup 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
    • connectFromField

      public GraphLookup connectFromField(String connectFromField)
      Field name whose value $graphLookup uses to recursively match against the connectToField of other documents in the collection. If the value is an array, each element is individually followed through the traversal process.
      Parameters:
      connectFromField - the field name
      Returns:
      this
    • connectToField

      public GraphLookup connectToField(String connectToField)
      Field name in other documents against which to match the value of the field specified by the connectFromField parameter.
      Parameters:
      connectToField - the field name
      Returns:
      this
    • depthField

      public GraphLookup depthField(String depthField)
      Optional. Name of the field to add to each traversed document in the search path. The value of this field is the recursion depth for the document, represented as a NumberLong. Recursion depth value starts at zero, so the first lookup corresponds to zero depth.
      Parameters:
      depthField - the field name
      Returns:
      this
    • maxDepth

      public GraphLookup maxDepth(Integer maxDepth)
      Optional. Non-negative integral number specifying the maximum recursion depth.
      Parameters:
      maxDepth - the max depth
      Returns:
      this
    • restrict

      public GraphLookup restrict(Filter... filters)
      Optional. A query specifying additional conditions for the recursive search
      Parameters:
      filters - the filters to restrict the matching
      Returns:
      this
    • startWith

      public GraphLookup startWith(Object startWith)
      Expression that specifies the value of the connectFromField with which to start the recursive search.
      Parameters:
      startWith - the expression defining the starting point
      Returns:
      this