org.apache.lucene.search

Class WildcardQuery



  • public class WildcardQuery
    extends AutomatonQuery
    Implements the wildcard search query. Supported wildcards are *, which matches any character sequence (including the empty one), and ?, which matches any single character. '\' is the escape character.

    Note this query can be slow, as it needs to iterate over many terms. In order to prevent extremely slow WildcardQueries, a Wildcard term should not start with the wildcard *

    This query uses the MultiTermQuery.CONSTANT_SCORE_REWRITE rewrite method.

    See Also:
    AutomatonQuery
    • Constructor Detail

      • WildcardQuery

        public WildcardQuery(Term term)
        Constructs a query for terms matching term.
      • WildcardQuery

        public WildcardQuery(Term term,
                             int maxDeterminizedStates)
        Constructs a query for terms matching term.
        Parameters:
        maxDeterminizedStates - maximum number of states in the resulting automata. If the automata would need more than this many states TooComplextToDeterminizeException is thrown. Higher number require more space but can process more complex automata.