Class BooleanQuery2ModifierNodeProcessor
- java.lang.Object
-
- org.apache.lucene.queryparser.flexible.standard.processors.BooleanQuery2ModifierNodeProcessor
-
- All Implemented Interfaces:
QueryNodeProcessor
public class BooleanQuery2ModifierNodeProcessor extends Object implements QueryNodeProcessor
This processor is used to apply the correctModifierQueryNodetoBooleanQueryNodes children. This is a variant ofBooleanModifiersQueryNodeProcessorwhich ignores precedence.The
StandardSyntaxParserknows the rules of precedence, but lucene does not. e.g.(A AND B OR C AND D)ist treated like(+A +B +C +D).This processor walks through the query node tree looking for
BooleanQueryNodes. If anAndQueryNodeis found, every child, which is not aModifierQueryNodeor theModifierQueryNodeisModifierQueryNode.Modifier.MOD_NONE, becomes aModifierQueryNode.Modifier.MOD_REQ. For defaultBooleanQueryNode, it checks the default operator isStandardQueryConfigHandler.Operator.AND, if it is, the same operation when anAndQueryNodeis found is applied to it. EachBooleanQueryNodewhich direct parent is also aBooleanQueryNodeis removed (to ignore the rules of precedence).
-
-
Constructor Summary
Constructors Constructor Description BooleanQuery2ModifierNodeProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidfillChildrenBufferAndApplyModifiery(QueryNode parent)QueryConfigHandlergetQueryConfigHandler()Returns theQueryConfigHandlerassociated to the query tree if any, otherwise it returnsnullprotected booleanisDefaultBooleanQueryNode(QueryNode toTest)protected QueryNodepostProcessNode(QueryNode node)protected QueryNodepreProcessNode(QueryNode node)QueryNodeprocess(QueryNode queryTree)Processes a query node tree.protected voidprocessChildren(QueryNode queryTree)voidsetQueryConfigHandler(QueryConfigHandler queryConfigHandler)Sets theQueryConfigHandlerassociated to the query tree.protected voidtagModifierButDoNotOverride(QueryNode node, ModifierQueryNode.Modifier mod)
-
-
-
Method Detail
-
process
public QueryNode process(QueryNode queryTree) throws QueryNodeException
Description copied from interface:QueryNodeProcessorProcesses a query node tree. It may return the same or another query tree. I should never returnnull.- Specified by:
processin interfaceQueryNodeProcessor- Parameters:
queryTree- tree root node- Returns:
- the processed query tree
- Throws:
QueryNodeException
-
processChildren
protected void processChildren(QueryNode queryTree) throws QueryNodeException
- Throws:
QueryNodeException
-
fillChildrenBufferAndApplyModifiery
protected void fillChildrenBufferAndApplyModifiery(QueryNode parent)
-
postProcessNode
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException
- Throws:
QueryNodeException
-
preProcessNode
protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException
- Throws:
QueryNodeException
-
isDefaultBooleanQueryNode
protected boolean isDefaultBooleanQueryNode(QueryNode toTest)
-
tagModifierButDoNotOverride
protected void tagModifierButDoNotOverride(QueryNode node, ModifierQueryNode.Modifier mod)
-
setQueryConfigHandler
public void setQueryConfigHandler(QueryConfigHandler queryConfigHandler)
Description copied from interface:QueryNodeProcessorSets theQueryConfigHandlerassociated to the query tree.- Specified by:
setQueryConfigHandlerin interfaceQueryNodeProcessor
-
getQueryConfigHandler
public QueryConfigHandler getQueryConfigHandler()
Description copied from interface:QueryNodeProcessorReturns theQueryConfigHandlerassociated to the query tree if any, otherwise it returnsnull- Specified by:
getQueryConfigHandlerin interfaceQueryNodeProcessor- Returns:
- the
QueryConfigHandlerassociated to the query tree if any, otherwise it returnsnull
-
-