Package org.apache.lucene.search
Class QueryVisitor
java.lang.Object
org.apache.lucene.search.QueryVisitor
Allows recursion through a query tree
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final QueryVisitor
A QueryVisitor implementation that does nothing -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptField
(String field) Whether or not terms from this field are of interest to the visitorvoid
consumeTerms
(Query query, Term... terms) Called by leaf queries that match on specific termsvoid
consumeTermsMatching
(Query query, String field, Supplier<ByteRunAutomaton> automaton) Called by leaf queries that match on a class of termsgetSubVisitor
(BooleanClause.Occur occur, Query parent) Pulls a visitor instance for visiting child clauses of a querystatic QueryVisitor
termCollector
(Set<Term> termSet) Builds aQueryVisitor
instance that collects all terms that may match a queryvoid
Called by leaf queries that do not match on terms
-
Field Details
-
EMPTY_VISITOR
A QueryVisitor implementation that does nothing
-
-
Constructor Details
-
QueryVisitor
public QueryVisitor()
-
-
Method Details
-
consumeTerms
Called by leaf queries that match on specific terms- Parameters:
query
- the leaf queryterms
- the terms the query will match on
-
consumeTermsMatching
Called by leaf queries that match on a class of terms- Parameters:
query
- the leaf queryfield
- the field queried againstautomaton
- a supplier for an automaton defining which terms match- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
visitLeaf
Called by leaf queries that do not match on terms- Parameters:
query
- the query
-
acceptField
Whether or not terms from this field are of interest to the visitorImplement this to avoid collecting terms from heavy queries such as
TermInSetQuery
that are not running on fields of interest -
getSubVisitor
Pulls a visitor instance for visiting child clauses of a queryThe default implementation returns
this
, unlessoccur
is equal toBooleanClause.Occur.MUST_NOT
in which case it returnsEMPTY_VISITOR
- Parameters:
occur
- the relationship between the parent and its childrenparent
- the query visited
-
termCollector
Builds aQueryVisitor
instance that collects all terms that may match a query- Parameters:
termSet
- aSet
to add collected terms to
-