TermInSetQuery

Specialization for a disjunction over many terms that, by default, behaves like a [ ] over a BooleanQuery containing only clauses.

For instance in the following example, both q1 and q2 would yield the same scores:

Query q1 = new TermInSetQuery("field", new BytesRef("foo"), new BytesRef("bar"));

BooleanQuery bq = new BooleanQuery();
bq.add(new TermQuery(new Term("field", "foo")), Occur.SHOULD);
bq.add(new TermQuery(new Term("field", "bar")), Occur.SHOULD);
Query q2 = new ConstantScoreQuery(bq);
*

Unless a custom MultiTermQuery.RewriteMethod is provided, this query executes like a regular disjunction where there are few terms. However, when there are many terms, instead of merging iterators on the fly, it will populate a bit set with matching docs for the least-costly terms and maintain a size-limited set of more costly iterators that are merged on the fly. For more details, see MultiTermQuery.CONSTANT_SCORE_BLENDED_REWRITE.

Users may also provide a custom MultiTermQuery.RewriteMethod to define different execution behavior, such as relying on doc values (see: ), or if scores are required (see: ). See MultiTermQuery documentation for more rewrite options.

NOTE: This query produces scores that are equal to its boost

Constructors

Link copied to clipboard
constructor(field: String, terms: MutableCollection<BytesRef>)
constructor(rewriteMethod: MultiTermQuery.RewriteMethod, field: String, terms: MutableCollection<BytesRef>)

Creates a new TermInSetQuery from the given collection of terms.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
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 override val field: String

Returns the field name for this query

Link copied to clipboard
open override 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(other: 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

Return the memory usage of this object in bytes. Negative values are illegal.

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(defaultField: String?): String

Prints a query to a string, with field assumed to be the default field and omitted.

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

Recurse through the query tree, visiting any child queries.