public abstract class QueryVisitor extends Object
Query.visit(QueryVisitor)
Modifier and Type | Field and Description |
---|---|
static QueryVisitor |
EMPTY_VISITOR
A QueryVisitor implementation that does nothing
|
Constructor and Description |
---|
QueryVisitor() |
Modifier and Type | Method and Description |
---|---|
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 as
TermInSetQuery
that are not running on fields of interest |
void |
consumeTerms(Query query,
Term... terms)
Called by leaf queries that match on specific terms
|
void |
consumeTermsMatching(Query query,
String field,
Supplier<ByteRunAutomaton> automaton)
Called by leaf queries that match on a class of terms
|
QueryVisitor |
getSubVisitor(BooleanClause.Occur occur,
Query parent)
Pulls a visitor instance for visiting child clauses of a query
The default implementation returns
this , unless occur is equal
to BooleanClause.Occur.MUST_NOT in which case it returns
EMPTY_VISITOR |
static QueryVisitor |
termCollector(Set<Term> termSet)
Builds a
QueryVisitor instance that collects all terms that may match a query |
void |
visitLeaf(Query query)
Called by leaf queries that do not match on terms
|
public static final QueryVisitor EMPTY_VISITOR
public void consumeTerms(Query query, Term... terms)
query
- the leaf queryterms
- the terms the query will match onpublic void consumeTermsMatching(Query query, String field, Supplier<ByteRunAutomaton> automaton)
query
- the leaf queryfield
- the field queried againstautomaton
- a supplier for an automaton defining which terms matchpublic void visitLeaf(Query query)
query
- the querypublic boolean acceptField(String field)
TermInSetQuery
that are not running on fields of interestpublic QueryVisitor getSubVisitor(BooleanClause.Occur occur, Query parent)
this
, unless occur
is equal
to BooleanClause.Occur.MUST_NOT
in which case it returns
EMPTY_VISITOR
occur
- the relationship between the parent and its childrenparent
- the query visitedpublic static QueryVisitor termCollector(Set<Term> termSet)
QueryVisitor
instance that collects all terms that may match a querytermSet
- a Set
to add collected terms toCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.