Class QueryVisitor

    • Field Detail


        public static final QueryVisitor EMPTY_VISITOR
        A QueryVisitor implementation that does nothing
    • Constructor Detail

      • QueryVisitor

        public QueryVisitor()
    • Method Detail

      • consumeTerms

        public void consumeTerms​(Query query,
                                 Term... terms)
        Called by leaf queries that match on specific terms
        query - the leaf query
        terms - the terms the query will match on
      • consumeTermsMatching

        public void consumeTermsMatching​(Query query,
                                         String field,
                                         Supplier<ByteRunAutomaton> automaton)
        Called by leaf queries that match on a class of terms
        query - the leaf query
        field - the field queried against
        automaton - 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

        public void visitLeaf​(Query query)
        Called by leaf queries that do not match on terms
        query - the query
      • acceptField

        public boolean acceptField​(String field)
        Whether or not this field is 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

      • getSubVisitor

        public 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

        occur - the relationship between the parent and its children
        parent - the query visited
      • termCollector

        public static QueryVisitor termCollector​(Set<Term> termSet)
        Builds a QueryVisitor instance that collects all terms that may match a query
        termSet - a Set to add collected terms to