Class QueryNodeProcessorImpl
java.lang.Object
org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl
- All Implemented Interfaces:
QueryNodeProcessor
- Direct Known Subclasses:
AllowLeadingWildcardProcessor
,AnalyzerQueryNodeProcessor
,BooleanModifiersQueryNodeProcessor
,BooleanSingleChildOptimizationQueryNodeProcessor
,BoostQueryNodeProcessor
,DefaultPhraseSlopQueryNodeProcessor
,FuzzyQueryNodeProcessor
,IntervalQueryNodeProcessor
,MatchAllDocsQueryNodeProcessor
,MultiFieldQueryNodeProcessor
,MultiTermRewriteMethodProcessor
,NoChildOptimizationQueryNodeProcessor
,OpenRangeQueryNodeProcessor
,PhraseSlopQueryNodeProcessor
,PointQueryNodeProcessor
,PointRangeQueryNodeProcessor
,RegexpQueryNodeProcessor
,RemoveDeletedQueryNodesProcessor
,RemoveEmptyNonLeafQueryNodeProcessor
,TermRangeQueryNodeProcessor
,WildcardQueryNodeProcessor
This is a default implementation for the
QueryNodeProcessor
interface, it's an abstract
class, so it should be extended by classes that want to process a QueryNode
tree.
This class process QueryNode
s from left to right in the tree. While it's walking down
the tree, for every node, preProcessNode(QueryNode)
is invoked. After a node's children
are processed, postProcessNode(QueryNode)
is invoked for that node. setChildrenOrder(List)
is invoked before postProcessNode(QueryNode)
only if the node
has at least one child, in setChildrenOrder(List)
the implementor might redefine the
children order or remove any children from the children list.
Here is an example about how it process the nodes:
a / \ b e / \ c dHere is the order the methods would be invoked for the tree described above:
preProcessNode( a ); preProcessNode( b ); preProcessNode( c ); postProcessNode( c ); preProcessNode( d ); postProcessNode( d ); setChildrenOrder( bChildrenList ); postProcessNode( b ); preProcessNode( e ); postProcessNode( e ); setChildrenOrder( aChildrenList ); postProcessNode( a )
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionFor reference about this method check:QueryNodeProcessor.getQueryConfigHandler()
.protected abstract QueryNode
postProcessNode
(QueryNode node) This method is invoked for every node when walking up the tree.protected abstract QueryNode
preProcessNode
(QueryNode node) This method is invoked for every node when walking down the tree.Processes a query node tree.protected void
processChildren
(QueryNode queryTree) This method is called every time a child is processed.setChildrenOrder
(List<QueryNode> children) This method is invoked for every node that has at least on child.void
setQueryConfigHandler
(QueryConfigHandler queryConfigHandler) For reference about this method check:QueryNodeProcessor.setQueryConfigHandler(QueryConfigHandler)
.
-
Constructor Details
-
QueryNodeProcessorImpl
public QueryNodeProcessorImpl() -
QueryNodeProcessorImpl
-
-
Method Details
-
process
Description copied from interface:QueryNodeProcessor
Processes a query node tree. It may return the same or another query tree. I should never returnnull
.- Specified by:
process
in interfaceQueryNodeProcessor
- Parameters:
queryTree
- tree root node- Returns:
- the processed query tree
- Throws:
QueryNodeException
-
processChildren
This method is called every time a child is processed.- Parameters:
queryTree
- the query node child to be processed- Throws:
QueryNodeException
- if something goes wrong during the query node processing
-
setQueryConfigHandler
For reference about this method check:QueryNodeProcessor.setQueryConfigHandler(QueryConfigHandler)
.- Specified by:
setQueryConfigHandler
in interfaceQueryNodeProcessor
- Parameters:
queryConfigHandler
- the query configuration handler to be set.- See Also:
-
getQueryConfigHandler
For reference about this method check:QueryNodeProcessor.getQueryConfigHandler()
.- Specified by:
getQueryConfigHandler
in interfaceQueryNodeProcessor
- Returns:
- QueryConfigHandler the query configuration handler to be set.
- See Also:
-
preProcessNode
This method is invoked for every node when walking down the tree.- Parameters:
node
- the query node to be pre-processed- Returns:
- a query node
- Throws:
QueryNodeException
- if something goes wrong during the query node processing
-
postProcessNode
This method is invoked for every node when walking up the tree.- Parameters:
node
- node the query node to be post-processed- Returns:
- a query node
- Throws:
QueryNodeException
- if something goes wrong during the query node processing
-
setChildrenOrder
protected abstract List<QueryNode> setChildrenOrder(List<QueryNode> children) throws QueryNodeException This method is invoked for every node that has at least on child. It's invoked right beforepostProcessNode(QueryNode)
is invoked.- Parameters:
children
- the list containing all current node's children- Returns:
- a new list containing all children that should be set to the current node
- Throws:
QueryNodeException
- if something goes wrong during the query node processing
-