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 correctModifierQueryNode
toBooleanQueryNode
s children. This is a variant ofBooleanModifiersQueryNodeProcessor
which ignores precedence.The
StandardSyntaxParser
knows 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
BooleanQueryNode
s. If anAndQueryNode
is found, every child, which is not aModifierQueryNode
or theModifierQueryNode
isModifierQueryNode.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 anAndQueryNode
is found is applied to it. EachBooleanQueryNode
which direct parent is also aBooleanQueryNode
is removed (to ignore the rules of precedence).
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList<QueryNode>
childrenBuffer
(package private) QueryConfigHandler
queryConfigHandler
(package private) static java.lang.String
TAG_BOOLEAN_ROOT
(package private) static java.lang.String
TAG_MODIFIER
(package private) static java.lang.String
TAG_REMOVE
private java.lang.Boolean
usingAnd
-
Constructor Summary
Constructors Constructor Description BooleanQuery2ModifierNodeProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private QueryNode
applyModifier(QueryNode node, ModifierQueryNode.Modifier mod)
protected void
fillChildrenBufferAndApplyModifiery(QueryNode parent)
QueryConfigHandler
getQueryConfigHandler()
Returns theQueryConfigHandler
associated to the query tree if any, otherwise it returnsnull
protected boolean
isDefaultBooleanQueryNode(QueryNode toTest)
protected QueryNode
postProcessNode(QueryNode node)
protected QueryNode
preProcessNode(QueryNode node)
QueryNode
process(QueryNode queryTree)
Processes a query node tree.protected void
processChildren(QueryNode queryTree)
private QueryNode
processIteration(QueryNode queryTree)
void
setQueryConfigHandler(QueryConfigHandler queryConfigHandler)
Sets theQueryConfigHandler
associated to the query tree.protected void
tagModifierButDoNotOverride(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: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
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:QueryNodeProcessor
Sets theQueryConfigHandler
associated to the query tree.- Specified by:
setQueryConfigHandler
in interfaceQueryNodeProcessor
-
getQueryConfigHandler
public QueryConfigHandler getQueryConfigHandler()
Description copied from interface:QueryNodeProcessor
Returns theQueryConfigHandler
associated to the query tree if any, otherwise it returnsnull
- Specified by:
getQueryConfigHandler
in interfaceQueryNodeProcessor
- Returns:
- the
QueryConfigHandler
associated to the query tree if any, otherwise it returnsnull
-
-