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
Creates a new TermInSetQuery from the given collection of terms.
Properties
Functions
Expert: Constructs an appropriate Weight implementation for this query.
Override and implement query instance equivalence properly in a subclass. This is required so that QueryCache works properly.
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.
Return the memory usage of this object in bytes. Negative values are illegal.
To rewrite to a simpler form, instead return a simpler enum from .getTermsEnum. For example, to rewrite to a single term, return a SingleTermsEnum
Recurse through the query tree, visiting any child queries.