public class TwigQuery extends NodeQuery
NodeQuery
that matches a boolean combination of Ancestor-Descendant
and Parent-Child node queries.
Code taken from BooleanQuery
and adapted for the Siren use case.
Modifier and Type | Class and Description |
---|---|
static class |
TwigQuery.EmptyRootQuery
An empty root query is used to create twig query in which the root query
is not specified.
|
protected class |
TwigQuery.TwigWeight
Expert: the Weight for
TwigQuery , used to
normalize, score and explain these queries. |
Modifier and Type | Field and Description |
---|---|
protected ArrayList<NodeBooleanClause> |
clauses |
ancestor, levelConstraint, lowerBound, upperBound
Constructor and Description |
---|
TwigQuery()
Constructs an empty twig query with a default level of 1.
|
TwigQuery(int rootLevel)
Constructs an empty twig query at a given level
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(NodeQuery query,
NodeBooleanClause.Occur occur)
Adds a child clause to the twig query.
|
protected void |
addClause(NodeBooleanClause clause)
Adds a clause to a twig query.
|
void |
addDescendant(int nodeLevel,
NodeQuery query,
NodeBooleanClause.Occur occur)
Adds a descendant clause to the twig query.
|
void |
addRoot(NodeQuery root)
Adds a root query.
|
List<NodeBooleanClause> |
clauses()
Returns the list of ancestor clauses in this query.
|
org.apache.lucene.search.Query |
clone() |
org.apache.lucene.search.Weight |
createWeight(org.apache.lucene.search.IndexSearcher searcher) |
boolean |
equals(Object o)
Returns true iff
o is equal to this. |
NodeBooleanClause[] |
getClauses()
Returns the set of ancestor clauses in this query.
|
static int |
getMaxClauseCount()
Return the maximum number of clauses permitted, 1024 by default.
|
NodeQuery |
getRoot()
Return the root of this query
|
int |
hashCode() |
Iterator<NodeBooleanClause> |
iterator()
Returns an iterator on the clauses in this query.
|
org.apache.lucene.search.Query |
rewrite(org.apache.lucene.index.IndexReader reader) |
protected void |
setAncestorPointer(NodeQuery ancestor)
Expert: Add a pointer to the node query ancestor
|
void |
setLevelConstraint(int levelConstraint)
Set a constraint on the node's level
|
static void |
setMaxClauseCount(int maxClauseCount)
Set the maximum number of clauses permitted per
TwigQuery . |
void |
setNodeConstraint(int lowerBound,
int upperBound)
Set an index interval constraint for a node.
|
String |
toString(String field) |
getDocsNodesAndPositionsEnum, getLevelConstraint, getNodeConstraint, setNodeConstraint
protected ArrayList<NodeBooleanClause> clauses
public TwigQuery(int rootLevel)
public TwigQuery()
public static int getMaxClauseCount()
NodeBooleanQuery.TooManyClauses
to be thrown.setMaxClauseCount(int)
public static void setMaxClauseCount(int maxClauseCount)
TwigQuery
. Default value
is 1024.public void addRoot(NodeQuery root)
Overwrite the level and node constraints of the root query with the currently defined level and node constraints of the twig query.
protected void addClause(NodeBooleanClause clause)
NodeBooleanQuery.TooManyClauses
- if the new number of clauses exceeds the maximum clause numbergetMaxClauseCount()
public void addChild(NodeQuery query, NodeBooleanClause.Occur occur)
NodeBooleanQuery.TooManyClauses
- if the new number of clauses exceeds the maximum clause numbergetMaxClauseCount()
public void addDescendant(int nodeLevel, NodeQuery query, NodeBooleanClause.Occur occur)
NodeBooleanQuery.TooManyClauses
- if the new number of clauses exceeds the maximum clause numbergetMaxClauseCount()
protected void setAncestorPointer(NodeQuery ancestor)
NodeQuery
The pointer to node query ancestor is used to retrieve node constraints from ancestors.
setAncestorPointer
in class NodeQuery
public void setNodeConstraint(int lowerBound, int upperBound)
NodeQuery
setNodeConstraint
in class NodeQuery
public void setLevelConstraint(int levelConstraint)
NodeQuery
Given that the root of the tree (level 0) is the document id, the node
level constraint ranges from 1 to Integer.MAX_VALUE
. A node
level constraint of 0 will always return false.
setLevelConstraint
in class NodeQuery
public NodeQuery getRoot()
public NodeBooleanClause[] getClauses()
public List<NodeBooleanClause> clauses()
public final Iterator<NodeBooleanClause> iterator()
Iterable
interface to make it possible to do:
for (SirenBooleanClause clause : booleanQuery) {}
public org.apache.lucene.search.Weight createWeight(org.apache.lucene.search.IndexSearcher searcher) throws IOException
createWeight
in class org.apache.lucene.search.Query
IOException
public org.apache.lucene.search.Query rewrite(org.apache.lucene.index.IndexReader reader) throws IOException
rewrite
in class org.apache.lucene.search.Query
IOException
public org.apache.lucene.search.Query clone()
clone
in class org.apache.lucene.search.Query
public String toString(String field)
toString
in class org.apache.lucene.search.Query
public boolean equals(Object o)
o
is equal to this.equals
in class org.apache.lucene.search.Query
public int hashCode()
hashCode
in class org.apache.lucene.search.Query
Copyright © 2014. All rights reserved.