Package org.apache.lucene.monitor
Class QueryTree
- java.lang.Object
-
- org.apache.lucene.monitor.QueryTree
-
- Direct Known Subclasses:
QueryTree.ConjunctionQueryTree
,QueryTree.DisjunctionQueryTree
public abstract class QueryTree extends java.lang.Object
A representation of a node in a query tree Queries are analyzed and converted into an abstract tree, consisting of conjunction and disjunction nodes, and leaf nodes containing terms. Terms may be collected from a node, which will use the weights of its sub-nodes to determine which paths are followed. The path may be changed by callingadvancePhase(double)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
QueryTree.ConjunctionQueryTree
private static class
QueryTree.DisjunctionQueryTree
-
Constructor Summary
Constructors Constructor Description QueryTree()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
advancePhase(double minWeight)
Find the next-most highly-weighted path below this nodestatic QueryTree
anyTerm(java.lang.String reason)
Returns a leaf node that will match any documentabstract void
collectTerms(java.util.function.BiConsumer<java.lang.String,BytesRef> termCollector)
Collect terms from the most highly-weighted path below this nodestatic QueryTree
conjunction(java.util.List<java.util.function.Function<TermWeightor,QueryTree>> children, TermWeightor weightor)
Returns a conjunction of a set of child nodes(package private) static QueryTree
conjunction(QueryTree... children)
static QueryTree
disjunction(java.util.List<java.util.function.Function<TermWeightor,QueryTree>> children, TermWeightor weightor)
Returns a disjunction of a set of child nodes(package private) static QueryTree
disjunction(QueryTree... children)
protected java.lang.String
space(int width)
Returns a string ofwidth
spacesstatic QueryTree
term(java.lang.String field, BytesRef term, double weight)
Returns a leaf node for a particular term and weight The weight must be greater than 0static QueryTree
term(Term term, double weight)
Returns a leaf node for a particular term and weight The weight must be greater than 0static QueryTree
term(Term term, TermWeightor weightor)
Returns a leaf node for a particular termjava.lang.String
toString()
abstract java.lang.String
toString(int depth)
Returns a string representation of the nodeabstract double
weight()
The weight of this node
-
-
-
Method Detail
-
weight
public abstract double weight()
The weight of this node
-
collectTerms
public abstract void collectTerms(java.util.function.BiConsumer<java.lang.String,BytesRef> termCollector)
Collect terms from the most highly-weighted path below this node
-
advancePhase
public abstract boolean advancePhase(double minWeight)
Find the next-most highly-weighted path below this node- Parameters:
minWeight
- do not advance if the next path has a weight below this value- Returns:
false
if there are no more paths above the minimum weight
-
toString
public abstract java.lang.String toString(int depth)
Returns a string representation of the node- Parameters:
depth
- the current depth of this node in the overall query tree
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
space
protected java.lang.String space(int width)
Returns a string ofwidth
spaces
-
term
public static QueryTree term(Term term, TermWeightor weightor)
Returns a leaf node for a particular term
-
term
public static QueryTree term(Term term, double weight)
Returns a leaf node for a particular term and weight The weight must be greater than 0
-
term
public static QueryTree term(java.lang.String field, BytesRef term, double weight)
Returns a leaf node for a particular term and weight The weight must be greater than 0
-
anyTerm
public static QueryTree anyTerm(java.lang.String reason)
Returns a leaf node that will match any document
-
conjunction
public static QueryTree conjunction(java.util.List<java.util.function.Function<TermWeightor,QueryTree>> children, TermWeightor weightor)
Returns a conjunction of a set of child nodes
-
disjunction
public static QueryTree disjunction(java.util.List<java.util.function.Function<TermWeightor,QueryTree>> children, TermWeightor weightor)
Returns a disjunction of a set of child nodes
-
-