Class RegexpQuery

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class RegexpQuery
    extends AutomatonQuery
    A fast regular expression query based on the org.apache.lucene.util.automaton package.
    • Comparisons are fast
    • The term dictionary is enumerated in an intelligent way, to avoid comparisons. See AutomatonQuery for more details.

    The supported syntax is documented in the RegExp class. Note this might be different than other regular expression implementations. For some alternatives with different syntax, look under the sandbox.

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

    See Also:
    RegExp
    • Constructor Detail

      • RegexpQuery

        public RegexpQuery​(Term term)
        Constructs a query for terms matching term.

        By default, all regular expression features are enabled.

        Parameters:
        term - regular expression.
      • RegexpQuery

        public RegexpQuery​(Term term,
                           int flags)
        Constructs a query for terms matching term.
        Parameters:
        term - regular expression.
        flags - optional RegExp features from RegExp
      • RegexpQuery

        public RegexpQuery​(Term term,
                           int flags,
                           AutomatonProvider provider)
        Constructs a query for terms matching term.
        Parameters:
        term - regular expression.
        flags - optional RegExp features from RegExp
        provider - custom AutomatonProvider for named automata
    • Method Detail

      • toString

        public java.lang.String toString​(java.lang.String field)
        Prints a user-readable version of this query.
        Overrides:
        toString in class AutomatonQuery