Package org.apache.lucene.search
Class QueryVisitor
- java.lang.Object
-
- org.apache.lucene.search.QueryVisitor
-
public abstract class QueryVisitor extends Object
Allows recursion through a query tree- See Also:
Query.visit(QueryVisitor)
-
-
Field Summary
Fields Modifier and Type Field Description static QueryVisitorEMPTY_VISITORA QueryVisitor implementation that does nothing
-
Constructor Summary
Constructors Constructor Description QueryVisitor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacceptField(String field)Whether or not terms from this field are of interest to the visitor Implement this to avoid collecting terms from heavy queries such asTermInSetQuerythat are not running on fields of interestvoidconsumeTerms(Query query, Term... terms)Called by leaf queries that match on specific termsQueryVisitorgetSubVisitor(BooleanClause.Occur occur, Query parent)Pulls a visitor instance for visiting child clauses of a query The default implementation returnsthis, unlessoccuris equal toBooleanClause.Occur.MUST_NOTin which case it returnsEMPTY_VISITORstatic QueryVisitortermCollector(Set<Term> termSet)Builds aQueryVisitorinstance that collects all terms that may match a queryvoidvisitLeaf(Query query)Called by leaf queries that do not match on terms
-
-
-
Field Detail
-
EMPTY_VISITOR
public static final QueryVisitor EMPTY_VISITOR
A QueryVisitor implementation that does nothing
-
-
Method Detail
-
consumeTerms
public void consumeTerms(Query query, Term... terms)
Called by leaf queries that match on specific terms- Parameters:
query- the leaf queryterms- the terms the query will match on
-
visitLeaf
public void visitLeaf(Query query)
Called by leaf queries that do not match on terms- Parameters:
query- the query
-
acceptField
public boolean acceptField(String field)
Whether or not terms from this field are of interest to the visitor Implement this to avoid collecting terms from heavy queries such asTermInSetQuerythat are not running on fields of interest
-
getSubVisitor
public QueryVisitor getSubVisitor(BooleanClause.Occur occur, Query parent)
Pulls a visitor instance for visiting child clauses of a query The default implementation returnsthis, unlessoccuris equal toBooleanClause.Occur.MUST_NOTin which case it returnsEMPTY_VISITOR- Parameters:
occur- the relationship between the parent and its childrenparent- the query visited
-
termCollector
public static QueryVisitor termCollector(Set<Term> termSet)
Builds aQueryVisitorinstance that collects all terms that may match a query- Parameters:
termSet- aSetto add collected terms to
-
-