List of usage examples for org.apache.lucene.queryparser.flexible.core.nodes ModifierQueryNode getModifier
public Modifier getModifier()
From source file:com.sindicetech.siren.qparser.keyword.builders.BooleanQueryNodeBuilder.java
License:Open Source License
private static BooleanClause.Occur getModifierValue(final QueryNode node) { if (node instanceof ModifierQueryNode) { final ModifierQueryNode mNode = ((ModifierQueryNode) node); switch (mNode.getModifier()) { case MOD_REQ: return BooleanClause.Occur.MUST; case MOD_NOT: return BooleanClause.Occur.MUST_NOT; case MOD_NONE: return BooleanClause.Occur.SHOULD; }/*from w ww.j a va2 s . c om*/ } return BooleanClause.Occur.SHOULD; }
From source file:com.sindicetech.siren.qparser.keyword.builders.NodeQueryBuilderUtil.java
License:Open Source License
/** * Returns the {@link NodeBooleanClause.Occur} that corresponds to the node * modifier.//w ww . j a v a 2s . com * * @param node the {@link ModifierQueryNode} * @param def the default {@link NodeBooleanClause.Occur} to return * if the node is not a {@link ModifierQueryNode} * @return the {@link NodeBooleanClause.Occur} of the query node */ static NodeBooleanClause.Occur getModifierValue(final QueryNode node, final NodeBooleanClause.Occur def) { if (node instanceof ModifierQueryNode) { final ModifierQueryNode mNode = ((ModifierQueryNode) node); switch (mNode.getModifier()) { case MOD_REQ: return NodeBooleanClause.Occur.MUST; case MOD_NOT: return NodeBooleanClause.Occur.MUST_NOT; case MOD_NONE: return NodeBooleanClause.Occur.SHOULD; } } return def; }
From source file:com.sindicetech.siren.qparser.keyword.processors.GroupQueryNodeProcessor.java
License:Open Source License
/** */// ww w . ja va2s. co m private QueryNode applyModifier(final QueryNode node, final QueryNode parent) { // if the default operator is AND if (this.usingAnd) { // if the parent is a or operator if (parent instanceof OrQueryNode) { // remove the modifier if (node instanceof ModifierQueryNode) { final ModifierQueryNode modNode = (ModifierQueryNode) node; if (modNode.getModifier() == Modifier.MOD_REQ) { return modNode.getChild(); } } // at this stage, the node does not have modifier, which means it is an SHOULD clause } // in any other case, add the MOD_REQ modifier as default else { if (node instanceof ModifierQueryNode) { final ModifierQueryNode modNode = (ModifierQueryNode) node; if (modNode.getModifier() == Modifier.MOD_NONE) { return new BooleanModifierNode(modNode.getChild(), Modifier.MOD_REQ); } } else { return new BooleanModifierNode(node, Modifier.MOD_REQ); } } } // if the default operator is OR else { // if the parent operator is AND if (parent instanceof AndQueryNode) { // add the MOD_REQ modifier if (node instanceof ModifierQueryNode) { final ModifierQueryNode modNode = (ModifierQueryNode) node; if (modNode.getModifier() == Modifier.MOD_NONE) { return new BooleanModifierNode(modNode.getChild(), Modifier.MOD_REQ); } } else { return new BooleanModifierNode(node, Modifier.MOD_REQ); } } } return node; }
From source file:com.sindicetech.siren.qparser.tree.builders.BooleanQueryNodeBuilder.java
License:Open Source License
private final NodeBooleanClause.Occur getNodeModifierValue(final QueryNode node) { if (node instanceof ModifierQueryNode) { final ModifierQueryNode mNode = ((ModifierQueryNode) node); switch (mNode.getModifier()) { case MOD_REQ: return NodeBooleanClause.Occur.MUST; case MOD_NOT: return NodeBooleanClause.Occur.MUST_NOT; case MOD_NONE: return NodeBooleanClause.Occur.SHOULD; }/* w w w. j a va2 s . c o m*/ } return NodeBooleanClause.Occur.SHOULD; }
From source file:com.sindicetech.siren.qparser.tree.builders.BooleanQueryNodeBuilder.java
License:Open Source License
private final BooleanClause.Occur getLuceneModifierValue(final QueryNode node) { if (node instanceof ModifierQueryNode) { final ModifierQueryNode mNode = ((ModifierQueryNode) node); switch (mNode.getModifier()) { case MOD_REQ: return BooleanClause.Occur.MUST; case MOD_NOT: return BooleanClause.Occur.MUST_NOT; case MOD_NONE: return BooleanClause.Occur.SHOULD; }/*from w ww . j av a2 s .co m*/ } return BooleanClause.Occur.SHOULD; }
From source file:com.sindicetech.siren.qparser.tree.builders.TwigQueryNodeBuilder.java
License:Open Source License
protected final NodeBooleanClause.Occur getModifierValue(final QueryNode node) { if (node instanceof ModifierQueryNode) { final ModifierQueryNode mNode = ((ModifierQueryNode) node); switch (mNode.getModifier()) { case MOD_REQ: return NodeBooleanClause.Occur.MUST; case MOD_NOT: return NodeBooleanClause.Occur.MUST_NOT; case MOD_NONE: return NodeBooleanClause.Occur.SHOULD; }//w w w.j ava 2 s. c om } return NodeBooleanClause.Occur.SHOULD; }
From source file:org.sindice.siren.qparser.json.builders.BooleanQueryNodeBuilder.java
License:Apache License
private static BooleanClause.Occur getModifierValue(final QueryNode node) { if (node instanceof ModifierQueryNode) { final ModifierQueryNode mNode = ((ModifierQueryNode) node); switch (mNode.getModifier()) { case MOD_REQ: return BooleanClause.Occur.MUST; case MOD_NOT: return BooleanClause.Occur.MUST_NOT; case MOD_NONE: return BooleanClause.Occur.SHOULD; }//from w w w . ja v a 2 s . c o m } return BooleanClause.Occur.SHOULD; }
From source file:org.sindice.siren.qparser.json.builders.TwigQueryNodeBuilder.java
License:Apache License
private static NodeBooleanClause.Occur getModifierValue(final QueryNode node) { if (node instanceof ModifierQueryNode) { final ModifierQueryNode mNode = ((ModifierQueryNode) node); switch (mNode.getModifier()) { case MOD_REQ: return NodeBooleanClause.Occur.MUST; case MOD_NOT: return NodeBooleanClause.Occur.MUST_NOT; case MOD_NONE: return NodeBooleanClause.Occur.SHOULD; }/*from w ww.j a v a 2 s . c om*/ } return NodeBooleanClause.Occur.SHOULD; }
From source file:org.sindice.siren.qparser.keyword.processors.GroupQueryNodeProcessor.java
License:Apache License
/** *//* w w w. jav a 2 s . c om*/ private QueryNode applyModifier(final QueryNode node, final QueryNode parent) { if (this.usingAnd) { if (parent instanceof OrQueryNode) { if (node instanceof ModifierQueryNode) { final ModifierQueryNode modNode = (ModifierQueryNode) node; if (modNode.getModifier() == Modifier.MOD_REQ) { return modNode.getChild(); } } } else { if (node instanceof ModifierQueryNode) { final ModifierQueryNode modNode = (ModifierQueryNode) node; if (modNode.getModifier() == Modifier.MOD_NONE) { return new BooleanModifierNode(modNode.getChild(), Modifier.MOD_REQ); } } else { return new BooleanModifierNode(node, Modifier.MOD_REQ); } } } else { if (parent instanceof AndQueryNode) { if (node instanceof ModifierQueryNode) { final ModifierQueryNode modNode = (ModifierQueryNode) node; if (modNode.getModifier() == Modifier.MOD_NONE) { return new BooleanModifierNode(modNode.getChild(), Modifier.MOD_REQ); } } else { return new BooleanModifierNode(node, Modifier.MOD_REQ); } } } return node; }