Class GraphLookup
- java.lang.Object
-
- dev.morphia.aggregation.experimental.stages.Stage
-
- dev.morphia.aggregation.experimental.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.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GraphLookup()
GraphLookup(Class from)
Creates a new stage using the target collection for the mapped typeGraphLookup(String from)
Creates a new stage using the target collection
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphLookup
as(String as)
Name of the array field added to each output document.GraphLookup
connectFromField(String connectFromField)
Field name whose value $graphLookup uses to recursively match against the connectToField of other documents in the collection.GraphLookup
connectToField(String connectToField)
Field name in other documents against which to match the value of the field specified by the connectFromField parameter.GraphLookup
depthField(String depthField)
Optional.static GraphLookup
from(Class from)
Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField.static GraphLookup
from(String from)
Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField.String
getAs()
String
getConnectFromField()
String
getConnectToField()
String
getDepthField()
String
getFrom()
Class
getFromType()
Integer
getMaxDepth()
Filter[]
getRestriction()
Expression
getStartWith()
GraphLookup
maxDepth(Integer maxDepth)
Optional.GraphLookup
restrict(Filter... filters)
Optional.GraphLookup
startWith(Expression startWith)
Expression that specifies the value of the connectFromField with which to start the recursive search.-
Methods inherited from class dev.morphia.aggregation.experimental.stages.Stage
getStageName
-
-
-
-
Constructor Detail
-
GraphLookup
public GraphLookup(String from)
Creates a new stage using the target collection- Parameters:
from
- the target collection
-
GraphLookup
protected GraphLookup()
-
GraphLookup
public GraphLookup(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
-
-
Method Detail
-
from
public static GraphLookup from(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
-
from
public static GraphLookup from(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
-
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
-
getAs
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.
-
getConnectFromField
public String getConnectFromField()
- 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.
-
getConnectToField
public String getConnectToField()
- 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.
-
getDepthField
public String getDepthField()
- 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
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
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.
-
getMaxDepth
public Integer getMaxDepth()
- 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.
-
getRestriction
public Filter[] getRestriction()
- 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.
-
getStartWith
public Expression getStartWith()
- 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.
-
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(Expression 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
-
-