Class QueryTreeWalker
- java.lang.Object
-
- com.lucidworks.search.dsl.DslBase
-
- com.lucidworks.search.dsl.request.query.walk.QueryTreeWalker
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
QueryTreeWalker.QueryWalkContext
-
Constructor Summary
Constructors Constructor Description QueryTreeWalker()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.stream.Stream<QueryTreeWalker.QueryWalkContext>
contextStream(QueryDefinition qd)
Creates a stream populated by a depth-first walk of the query-tree Callers should beware using theQueryTreeWalker.QueryWalkContext
to modify the links between queries as tree branches may be orphaned or dropped from iteration as a result.void
depthFirstWalk(QueryDefinition queryDefinition, java.util.function.Function<QueryTreeWalker.QueryWalkContext,QueryTreeAction> perNodeAction)
Performs a depth-first walk of the main query in the specifiedQueryDefinition
Our walk processes the whole tree by default.
-
-
-
Method Detail
-
depthFirstWalk
public void depthFirstWalk(QueryDefinition queryDefinition, java.util.function.Function<QueryTreeWalker.QueryWalkContext,QueryTreeAction> perNodeAction)
Performs a depth-first walk of the main query in the specifiedQueryDefinition
Our walk processes the whole tree by default. However, if the provided callback replaces the Query currently being processed, the walk skips over any children in that subtree to limit the risk of accidental infinite-recursion or double-visiting.- Parameters:
queryDefinition
- the DSL definition containing the query-tree to walkperNodeAction
- a Function to process each node as it's visited. If any modifications are being made to the node (or its children), the Function can return a new query object which should replace the current query's position within the tree. Function's that don't modify the tree in any way can return the Query object attached to the current QueryWalkContext
-
contextStream
public static java.util.stream.Stream<QueryTreeWalker.QueryWalkContext> contextStream(QueryDefinition qd)
Creates a stream populated by a depth-first walk of the query-tree Callers should beware using theQueryTreeWalker.QueryWalkContext
to modify the links between queries as tree branches may be orphaned or dropped from iteration as a result.
-
-