Class BooleanQuery2ModifierNodeProcessor
- java.lang.Object
-
- org.apache.lucene.queryparser.flexible.standard.processors.BooleanQuery2ModifierNodeProcessor
-
- All Implemented Interfaces:
QueryNodeProcessor
public class BooleanQuery2ModifierNodeProcessor extends java.lang.Object implements QueryNodeProcessor
This processor is used to apply the correct
ModifierQueryNodetoBooleanQueryNodes 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).
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList<QueryNode>childrenBuffer(package private) QueryConfigHandlerqueryConfigHandler(package private) static java.lang.StringTAG_BOOLEAN_ROOT(package private) static java.lang.StringTAG_MODIFIER(package private) static java.lang.StringTAG_REMOVEprivate java.lang.BooleanusingAnd
-
Constructor Summary
Constructors Constructor Description BooleanQuery2ModifierNodeProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private QueryNodeapplyModifier(QueryNode node, ModifierQueryNode.Modifier mod)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)private QueryNodeprocessIteration(QueryNode queryTree)voidsetQueryConfigHandler(QueryConfigHandler queryConfigHandler)Sets theQueryConfigHandlerassociated to the query tree.protected voidtagModifierButDoNotOverride(QueryNode node, ModifierQueryNode.Modifier mod)
-
-
-
Field Detail
-
TAG_REMOVE
static final java.lang.String TAG_REMOVE
- See Also:
- Constant Field Values
-
TAG_MODIFIER
static final java.lang.String TAG_MODIFIER
- See Also:
- Constant Field Values
-
TAG_BOOLEAN_ROOT
static final java.lang.String TAG_BOOLEAN_ROOT
- See Also:
- Constant Field Values
-
queryConfigHandler
QueryConfigHandler queryConfigHandler
-
childrenBuffer
private final java.util.ArrayList<QueryNode> childrenBuffer
-
usingAnd
private java.lang.Boolean usingAnd
-
-
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
-
processIteration
private QueryNode processIteration(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)
-
applyModifier
private QueryNode applyModifier(QueryNode node, ModifierQueryNode.Modifier mod)
-
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
-
-