Class RemoveEmptyNonLeafQueryNodeProcessor
- java.lang.Object
-
- org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl
-
- org.apache.lucene.queryparser.flexible.standard.processors.RemoveEmptyNonLeafQueryNodeProcessor
-
- All Implemented Interfaces:
QueryNodeProcessor
public class RemoveEmptyNonLeafQueryNodeProcessor extends QueryNodeProcessorImpl
This processor removes everyQueryNode
that is not a leaf and has not children. If after processing the entire tree the root node is not a leaf and has no children, aMatchNoDocsQueryNode
object is returned.
This processor is used at the end of a pipeline to avoid invalid query node tree structures like aGroupQueryNode
orModifierQueryNode
with no children.- See Also:
QueryNode
,MatchNoDocsQueryNode
-
-
Constructor Summary
Constructors Constructor Description RemoveEmptyNonLeafQueryNodeProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected QueryNode
postProcessNode(QueryNode node)
This method is invoked for every node when walking up the tree.protected QueryNode
preProcessNode(QueryNode node)
This method is invoked for every node when walking down the tree.QueryNode
process(QueryNode queryTree)
Processes a query node tree.protected List<QueryNode>
setChildrenOrder(List<QueryNode> children)
This method is invoked for every node that has at least on child.-
Methods inherited from class org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl
getQueryConfigHandler, processChildren, setQueryConfigHandler
-
-
-
-
Method Detail
-
process
public QueryNode process(QueryNode queryTree) throws QueryNodeException
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
- Overrides:
process
in classQueryNodeProcessorImpl
- Parameters:
queryTree
- tree root node- Returns:
- the processed query tree
- Throws:
QueryNodeException
-
postProcessNode
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException
Description copied from class:QueryNodeProcessorImpl
This method is invoked for every node when walking up the tree.- Specified by:
postProcessNode
in classQueryNodeProcessorImpl
- 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
-
preProcessNode
protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException
Description copied from class:QueryNodeProcessorImpl
This method is invoked for every node when walking down the tree.- Specified by:
preProcessNode
in classQueryNodeProcessorImpl
- Parameters:
node
- the query node to be pre-processed- Returns:
- a query node
- Throws:
QueryNodeException
- if something goes wrong during the query node processing
-
setChildrenOrder
protected List<QueryNode> setChildrenOrder(List<QueryNode> children) throws QueryNodeException
Description copied from class:QueryNodeProcessorImpl
This method is invoked for every node that has at least on child. It's invoked right beforeQueryNodeProcessorImpl.postProcessNode(QueryNode)
is invoked.- Specified by:
setChildrenOrder
in classQueryNodeProcessorImpl
- 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
-
-