RegexpQuery

class RegexpQuery(term: Term, syntaxFlags: Int, matchFlags: Int, provider: AutomatonProvider, determinizeWorkLimit: Int, rewriteMethod: MultiTermQuery.RewriteMethod, doDeterminization: Boolean = true) : AutomatonQuery

A fast regular expression query based on the org.gnit.lucenekmp.util.automaton package.

  • Comparisons are fast

  • The term dictionary is enumerated in an intelligent way, to avoid comparisons. See [ ] 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

Constructors

Link copied to clipboard
constructor(term: Term, syntaxFlags: Int, matchFlags: Int, provider: AutomatonProvider, determinizeWorkLimit: Int, rewriteMethod: MultiTermQuery.RewriteMethod, doDeterminization: Boolean = true)
constructor(term: Term, flags: Int = RegExp.ALL)

Constructs a query for terms matching term.

constructor(term: Term, flags: Int, determinizeWorkLimit: Int)

Constructs a query for terms matching term.

constructor(term: Term, syntaxFlags: Int, matchFlags: Int, determinizeWorkLimit: Int)

Constructs a query for terms matching term.

constructor(term: Term, syntaxFlags: Int, provider: AutomatonProvider, determinizeWorkLimit: Int)

Constructs a query for terms matching term.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Returns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).

Link copied to clipboard
open val field: String

Returns the field name for this query

Link copied to clipboard

Is this a binary (byte) oriented automaton. See the constructor.

Link copied to clipboard
Link copied to clipboard
open val termsCount: Long

Functions

Link copied to clipboard
open fun createWeight(searcher: IndexSearcher, scoreMode: ScoreMode, boost: Float): Weight

Expert: Constructs an appropriate Weight implementation for this query.

Link copied to clipboard
open operator override fun equals(obj: Any?): Boolean

Override and implement query instance equivalence properly in a subclass. This is required so that QueryCache works properly.

Link copied to clipboard

Constructs an enumeration that expands the pattern term. This method should only be called if the field exists (ie, implementations can assume the field does exist). This method never returns null. The returned TermsEnum is positioned to the first matching term.

Link copied to clipboard
open override fun hashCode(): Int

Override and implement query hash code properly in a subclass. This is required so that [ ] works properly.

Link copied to clipboard
open override fun ramBytesUsed(): Long

Returns the automaton used to create this query

Link copied to clipboard
open override fun rewrite(indexSearcher: IndexSearcher): Query

To rewrite to a simpler form, instead return a simpler enum from .getTermsEnum. For example, to rewrite to a single term, return a SingleTermsEnum

Link copied to clipboard
open override fun toString(): String

Prints a query to a string.

open override fun toString(field: String?): String

Prints a user-readable version of this query.

Link copied to clipboard
open override fun visit(visitor: QueryVisitor)

Recurse through the query tree, visiting any child queries.