Intervals

object Intervals

Factory functions for creating IntervalsSource interval sources.

These sources implement minimum-interval algorithms taken from the paper [Efficient Optimally Lazy Algorithms for Minimal-Interval Semantics](https://vigna.di.unimi.it/ftp/papers/EfficientLazy.pdf)

Note: by default, sources that are sensitive to internal gaps (e.g. `PHRASE` and `MAXGAPS`) will rewrite their sub-sources so that disjunctions of different lengths are pulled up to the top of the interval tree. For example, `PHRASE(or(PHRASE("a", "b", "c"), "b"), "c")` will automatically rewrite itself to `OR(PHRASE("a", "b", "c", "c"), PHRASE("b", "c"))` to ensure that documents containing `"b c"` are matched. This can lead to less efficient queries, as more terms need to be loaded (for example, the `"c"` iterator above is loaded twice), so if you care more about speed than about accuracy you can use the [or] factory method to prevent rewriting.

Properties

Link copied to clipboard
const val DEFAULT_MAX_EXPANSIONS: Int = 128

The default number of expansions in:

Functions

Link copied to clipboard

Returns intervals from the source that appear after intervals from the reference

Link copied to clipboard
fun analyzedText(tokenStream: TokenStream, maxGaps: Int, ordered: Boolean): IntervalsSource

Returns intervals that correspond to tokens from the provided TokenStream. This is a low-level counterpart to analyzedText. The intervals can be ordered or unordered and can have optional gaps inside.

fun analyzedText(text: String, analyzer: Analyzer, field: String, maxGaps: Int, ordered: Boolean): IntervalsSource

Returns intervals that correspond to tokens from a TokenStream returned for text by applying the provided Analyzer as if text was the content of the given field. The intervals can be ordered or unordered and can have optional gaps inside.

Link copied to clipboard
fun atLeast(minShouldMatch: Int, vararg sources: IntervalsSource): IntervalsSource

Return intervals that span combinations of intervals from minShouldMatch of the sources

Link copied to clipboard

Returns intervals from the source that appear before intervals from the reference

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun extend(source: IntervalsSource, before: Int, after: Int): IntervalsSource

Create an IntervalsSource that wraps another source, extending its intervals by a number of positions before and after.

Link copied to clipboard

Create an IntervalsSource that always returns intervals from a specific field

Link copied to clipboard
fun fuzzyTerm(term: String, maxEdits: Int): IntervalsSource
fun fuzzyTerm(term: String, maxEdits: Int, prefixLength: Int, transpositions: Boolean, maxExpansions: Int): IntervalsSource

A fuzzy term IntervalsSource matches the disjunction of intervals of terms that are within the specified maxEdits from the provided term.

Link copied to clipboard
fun maxgaps(gaps: Int, subSource: IntervalsSource): IntervalsSource

Create an IntervalsSource that filters a sub-source by its gaps

Link copied to clipboard
fun maxwidth(width: Int, subSource: IntervalsSource): IntervalsSource

Create an IntervalsSource that filters a sub-source by the width of its intervals

Link copied to clipboard
fun multiterm(ca: CompiledAutomaton, maxExpansions: Int, pattern: String): IntervalsSource

Expert: Return an IntervalsSource over the disjunction of all terms that are accepted by the given automaton

Link copied to clipboard

Returns a source that produces no intervals

Link copied to clipboard

Create a non-overlapping IntervalsSource

Link copied to clipboard
Link copied to clipboard

Create a not-containing IntervalsSource

Link copied to clipboard
fun notWithin(minuend: IntervalsSource, positions: Int, subtrahend: IntervalsSource): IntervalsSource

Create a not-within IntervalsSource

Link copied to clipboard
fun or(vararg subSources: IntervalsSource): IntervalsSource
fun or(rewrite: Boolean, subSources: List<IntervalsSource>): IntervalsSource
fun or(rewrite: Boolean, vararg subSources: IntervalsSource): IntervalsSource

Return an IntervalsSource over the disjunction of a set of sub-sources

Link copied to clipboard
fun ordered(vararg subSources: IntervalsSource): IntervalsSource

Create an ordered IntervalsSource

Link copied to clipboard

Returns intervals from a source that overlap with intervals from another source

Link copied to clipboard
fun phrase(vararg terms: String): IntervalsSource

Return an IntervalsSource exposing intervals for a phrase consisting of a list of terms

fun phrase(vararg subSources: IntervalsSource): IntervalsSource

Return an IntervalsSource exposing intervals for a phrase consisting of a list of IntervalsSource interval sources

Link copied to clipboard

Return an IntervalsSource over the disjunction of all terms that begin with a prefix

fun prefix(prefix: BytesRef, maxExpansions: Int): IntervalsSource

Expert: Return an IntervalsSource over the disjunction of all terms that begin with a prefix

Link copied to clipboard
fun range(lowerTerm: BytesRef?, upperTerm: BytesRef?, includeLower: Boolean, includeUpper: Boolean): IntervalsSource

Return an IntervalsSource over the disjunction of all terms that fall within the given range

fun range(lowerTerm: BytesRef?, upperTerm: BytesRef?, includeLower: Boolean, includeUpper: Boolean, maxExpansions: Int): IntervalsSource

Expert: Return an IntervalsSource over the disjunction of all terms that fall within the given range

Link copied to clipboard

Return an IntervalsSource over the disjunction of all terms that match a regular expression

fun regexp(regexp: BytesRef, maxExpansions: Int): IntervalsSource

Expert: Return an IntervalsSource over the disjunction of all terms that match a regular expression

Link copied to clipboard

Return an IntervalsSource exposing intervals for a term

fun term(term: String, payloadFilter: (BytesRef?) -> Boolean): IntervalsSource
fun term(term: BytesRef, payloadFilter: (BytesRef?) -> Boolean): IntervalsSource

Return an IntervalsSource exposing intervals for a term, filtered by the value of the term's payload at each position

Link copied to clipboard
fun unordered(vararg subSources: IntervalsSource): IntervalsSource

Create an unordered IntervalsSource. Note that if there are multiple intervals ends at the same position are eligible, only the narrowest one will be returned. For example if asking for unordered(term("apple"), term("banana")) on field of "apple wolf apple orange banana", only the "apple orange banana" will be returned.

Link copied to clipboard

Create an unordered IntervalsSource allowing no overlaps between subsources

Link copied to clipboard

Return an IntervalsSource over the disjunction of all terms that match a wildcard glob

fun wildcard(wildcard: BytesRef, maxExpansions: Int): IntervalsSource

Expert: Return an IntervalsSource over the disjunction of all terms that match a wildcard glob

Link copied to clipboard
fun within(source: IntervalsSource, positions: Int, reference: IntervalsSource): IntervalsSource

Returns intervals of the source that appear within a set number of positions of intervals from the reference