IndexOrDocValuesQuery

class IndexOrDocValuesQuery(val indexQuery: Query, val randomAccessQuery: Query) : Query

A query that uses either an index structure (points or terms) or doc values in order to run a query, depending which one is more efficient. This is typically useful for range queries, whose Weight.scorer is costly to create since it usually needs to sort large lists of doc ids. For instance, for a field that both indexed LongPoints and [ ]s with the same values, an efficient range query could be created by doing:

String field;
long minValue, maxValue;
Query pointQuery = LongPoint.newRangeQuery(field, minValue, maxValue);
Query dvQuery = SortedNumericDocValuesField.newSlowRangeQuery(field, minValue, maxValue);
Query query = new IndexOrDocValuesQuery(pointQuery, dvQuery);
*

The above query will be efficient as it will use points in the case that they perform better, ie. when we need a good lead iterator that will be almost entirely consumed; and doc values otherwise, ie. in the case that another part of the query is already leading iteration but we still need the ability to verify that some documents match.

Some field types that work well with IndexOrDocValuesQuery are [ ], org.gnit.lucenekmp.document.LongField, [ ], org.gnit.lucenekmp.document.DoubleField, and org.gnit.lucenekmp.document.KeywordField. These fields provide both an indexed structure and doc values.

NOTEThis query currently only works well with point range/exact queries and their equivalent doc values queries.

Constructors

Link copied to clipboard
constructor(indexQuery: Query, randomAccessQuery: Query)

Properties

Link copied to clipboard

Return the wrapped query that may be costly to initialize but has a good iterator.

Link copied to clipboard

Return the wrapped query that may be slow at identifying all matching documents, but which is cheap to initialize and can efficiently verify that some documents match.

Functions

Link copied to clipboard
open override 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
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 rewrite(indexSearcher: IndexSearcher): Query

Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.

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

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

open override fun toString(): String

Prints a query to a string.

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

Recurse through the query tree, visiting any child queries.