Class WildcardQuery

  • All Implemented Interfaces:
    Accountable

    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
    • Field Detail

      • WILDCARD_STRING

        public static final char WILDCARD_STRING
        String equality with support for wildcards
        See Also:
        Constant Field Values
      • WILDCARD_CHAR

        public static final char WILDCARD_CHAR
        Char equality with support for wildcards
        See Also:
        Constant Field Values
      • WILDCARD_ESCAPE

        public static final char WILDCARD_ESCAPE
        Escape character
        See Also:
        Constant Field Values
    • 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.
    • Method Detail

      • toAutomaton

        public static Automaton toAutomaton​(Term wildcardquery)
        Convert Lucene wildcard syntax into an automaton.
        NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
      • getTerm

        public Term getTerm()
        Returns the pattern term.