org.apache.lucene.search

## Class IndexSortSortedNumericDocValuesRangeQuery

- java.lang.Object
- - org.apache.lucene.search.Query
  - - org.apache.lucene.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 `SortedNumericDocValues` or `NumericDocValues`.
  - The segments must have at most one field value per document (otherwise we cannot easily determine the matching document IDs through a binary search).
  If any of these conditions isn't met, the search is delegated to `fallbackQuery`. This fallback must be an equivalent range query -- it should produce the same documents and give constant scores. As an example, an `IndexSortSortedNumericDocValuesRangeQuery` might 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 and Description
    `IndexSortSortedNumericDocValuesRangeQuery(String field, long lowerValue, long upperValue, Query fallbackQuery)` Creates a new `IndexSortSortedNumericDocValuesRangeQuery`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Weight` | `createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost)`
    `boolean` | `equals(Object o)`
    `Query` | `getFallbackQuery()`
    `int` | `hashCode()`
    `Query` | `rewrite(IndexReader reader)`
    `String` | `toString(String field)`
    `void` | `visit(QueryVisitor visitor)`

    - ### Methods inherited from class org.apache.lucene.search.Query

      `classHash, sameClassAs, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### IndexSortSortedNumericDocValuesRangeQuery

          public IndexSortSortedNumericDocValuesRangeQuery(String field,
                                                           long lowerValue,
                                                           long upperValue,
                                                           Query fallbackQuery)

      Creates a new `IndexSortSortedNumericDocValuesRangeQuery`.
      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()

    - #### equals

          public boolean equals(Object o)

      Specified by:
        `equals` in class `Query`

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in class `Query`

    - #### visit

          public void visit(QueryVisitor visitor)

      Overrides:
        `visit` in class `Query`

    - #### toString

          public String toString(String field)

      Specified by:
        `toString` in class `Query`

    - #### rewrite

          public Query rewrite(IndexReader reader)
                        throws IOException

      Overrides:
        `rewrite` in class `Query`
      Throws:
        `IOException`

    - #### createWeight

          public Weight createWeight(IndexSearcher searcher,
                                     ScoreMode scoreMode,
                                     float boost)
                              throws IOException

      Overrides:
        `createWeight` in class `Query`
      Throws:
        `IOException`

Copyright © 2000-2024 Apache Software Foundation. All Rights Reserved.