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 determinizeWorkLimit)
        Constructs a query for terms matching term.
        Parameters:
        determinizeWorkLimit - maximum effort to spend while compiling the automaton from this wildcard. Set higher to allow more complex queries and lower to prevent memory exhaustion. Use Operations.DEFAULT_DETERMINIZE_WORK_LIMIT as a decent default if you don't otherwise know what to specify.
      • WildcardQuery

        public WildcardQuery​(Term term,
                             int determinizeWorkLimit,
                             MultiTermQuery.RewriteMethod rewriteMethod)
        Constructs a query for terms matching term.
        Parameters:
        determinizeWorkLimit - maximum effort to spend while compiling the automaton from this wildcard. Set higher to allow more complex queries and lower to prevent memory exhaustion. Use Operations.DEFAULT_DETERMINIZE_WORK_LIMIT as a decent default if you don't otherwise know what to specify.
        rewriteMethod - the rewrite method to use when building the final query
    • 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.