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 Deprecated 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)
Deprecated, for removal: This API element is subject to removal in a future version.static GraphLookup
from(String from)
Deprecated, for removal: This API element is subject to removal in a future version.usergraphLookup(String)
String
getAs()
String
getConnectFromField()
String
getConnectToField()
String
getDepthField()
String
getFrom()
Class
getFromType()
Integer
getMaxDepth()
Filter[]
getRestriction()
Expression
getStartWith()
static GraphLookup
graphLookup(Class<?> from)
Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField.static GraphLookup
graphLookup(String from)
Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField.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
aggregation, stageName
-
-
-
-
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
@Deprecated(forRemoval=true) public static GraphLookup from(String from)
Deprecated, for removal: This API element is subject to removal in a future version.usergraphLookup(String)
Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField.- Parameters:
from
- the target collection name- Returns:
- this
-
from
@Deprecated(forRemoval=true) public static GraphLookup from(Class from)
Deprecated, for removal: This API element is subject to removal in a future version.Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField.- Parameters:
from
- the target collection name- Returns:
- this
-
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
-
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
-
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
@Nullable 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
@Nullable 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
@Nullable 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
@Nullable 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
@Nullable 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 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
@Nullable 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
@Nullable 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
@Nullable 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
-
-