Package org.apache.lucene.sandbox.search
Class IndexSortSortedNumericDocValuesRangeQuery
- java.lang.Object
-
- org.apache.lucene.search.Query
-
- org.apache.lucene.sandbox.search.IndexSortSortedNumericDocValuesRangeQuery
-
public class IndexSortSortedNumericDocValuesRangeQuery extends Query
A range query that can take advantage of the fact that the index is sorted to speed up execution. If the index is sorted on the same field as the query, it performs binary search on the field's numeric doc values to find the documents at the lower and upper ends of the range.This optimized execution strategy is only used if the following conditions hold:
- The index is sorted, and its primary sort is on the same field as the query.
- The query field has either
SortedNumericDocValuesorNumericDocValues. - The sort field is of type
SortField.Type.LONGorSortField.Type.INT. - The segments must have at most one field value per document (otherwise we cannot easily determine the matching document IDs through a binary search).
fallbackQuery.This fallback must be an equivalent range query -- it should produce the same documents and give constant scores. As an example, an
IndexSortSortedNumericDocValuesRangeQuerymight be constructed as follows:String field = "field"; long lowerValue = 0, long upperValue = 10; Query fallbackQuery = LongPoint.newRangeQuery(field, lowerValue, upperValue); Query rangeQuery = new IndexSortSortedNumericDocValuesRangeQuery( field, lowerValue, upperValue, fallbackQuery);- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description IndexSortSortedNumericDocValuesRangeQuery(String field, long lowerValue, long upperValue, Query fallbackQuery)Creates a newIndexSortSortedNumericDocValuesRangeQuery.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WeightcreateWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost)booleanequals(Object o)QuerygetFallbackQuery()inthashCode()Queryrewrite(IndexReader reader)StringtoString(String field)voidvisit(QueryVisitor visitor)-
Methods inherited from class org.apache.lucene.search.Query
classHash, sameClassAs, toString
-
-
-
-
Constructor Detail
-
IndexSortSortedNumericDocValuesRangeQuery
public IndexSortSortedNumericDocValuesRangeQuery(String field, long lowerValue, long upperValue, Query fallbackQuery)
Creates a newIndexSortSortedNumericDocValuesRangeQuery.- Parameters:
field- The field name.lowerValue- The lower end of the range (inclusive).upperValue- The upper end of the range (exclusive).fallbackQuery- A query to fall back to if the optimization cannot be applied.
-
-
Method Detail
-
getFallbackQuery
public Query getFallbackQuery()
-
visit
public void visit(QueryVisitor visitor)
-
rewrite
public Query rewrite(IndexReader reader) throws IOException
- Overrides:
rewritein classQuery- Throws:
IOException
-
createWeight
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException
- Overrides:
createWeightin classQuery- Throws:
IOException
-
-