Package dev.morphia.aggregation.stages
Class GraphLookup
java.lang.Object
dev.morphia.aggregation.stages.Stage
dev.morphia.aggregation.stages.GraphLookup
Performs a recursive search on a collection, with options for restricting the search by recursion depth and query filter.
-
Method Summary
Modifier and TypeMethodDescriptionName of the array field added to each output document.connectFromField
(String connectFromField) Field name whose value $graphLookup uses to recursively match against the connectToField of other documents in the collection.connectToField
(String connectToField) Field name in other documents against which to match the value of the field specified by the connectFromField parameter.depthField
(String depthField) Optional.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.Optional.Optional.Expression that specifies the value of the connectFromField with which to start the recursive search.
-
Method Details
-
graphLookup
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
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
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
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
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
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
Optional. Non-negative integral number specifying the maximum recursion depth.- Parameters:
maxDepth
- the max depth- Returns:
- this
-
restrict
Optional. A query specifying additional conditions for the recursive search- Parameters:
filters
- the filters to restrict the matching- Returns:
- this
-
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
-