IndexOrDocValuesQuery
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.
Properties
Return the wrapped query that may be costly to initialize but has a good iterator.
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
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.
Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.
Recurse through the query tree, visiting any child queries.