org.apache.lucene.search.comparators

## Class NumericComparator<T extends Number>

- java.lang.Object
- - org.apache.lucene.search.FieldComparator<T>
  - - org.apache.lucene.search.comparators.NumericComparator<T>

- Direct Known Subclasses:
    DoubleComparator, FloatComparator, IntComparator, LongComparator

      public abstract class NumericComparator<T extends Number>
      extends FieldComparator<T>

  Abstract numeric comparator for comparing numeric values. This comparator provides a skipping functionality – an iterator that can skip over non-competitive documents.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `NumericComparator.NumericLeafComparator` Leaf comparator for `NumericComparator` that provides skipping functionality

    - ### Nested classes/interfaces inherited from class org.apache.lucene.search.FieldComparator

      `FieldComparator.RelevanceComparator, FieldComparator.TermOrdValComparator, FieldComparator.TermValComparator`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `field`
    `protected boolean` | `hitsThresholdReached`
    `protected T` | `missingValue`
    `protected boolean` | `primarySort`
    `protected boolean` | `queueFull`
    `protected boolean` | `reverse`
    `protected boolean` | `singleSort`
    `protected boolean` | `topValueSet`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `NumericComparator(String field, T missingValue, boolean reverse, int sortPos, int bytesCount)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `setCanUsePoints()` For numeric comparators, setting this value, indicates that the same numeric data has been indexed with two fields: doc values and points and that these fields have the same name.
    `void` | `setSingleSort()` Informs the comparator that sort is done on this single field.
    `void` | `setTopValue(T value)` Record the top value, for future calls to `LeafFieldComparator.compareTop(int)`.

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

      `compare, compareValues, getLeafComparator, value`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### missingValue

          protected final T extends Number missingValue

    - #### field

          protected final String field

    - #### reverse

          protected final boolean reverse

    - #### primarySort

          protected final boolean primarySort

    - #### topValueSet

          protected boolean topValueSet

    - #### singleSort

          protected boolean singleSort

    - #### hitsThresholdReached

          protected boolean hitsThresholdReached

    - #### queueFull

          protected boolean queueFull

  - ### Constructor Detail

    - #### NumericComparator

          protected NumericComparator(String field,
                                      T missingValue,
                                      boolean reverse,
                                      int sortPos,
                                      int bytesCount)

  - ### Method Detail

    - #### setCanUsePoints

          public void setCanUsePoints()

      Description copied from class: `FieldComparator`
      For numeric comparators, setting this value, indicates that the same numeric data has been indexed with two fields: doc values and points and that these fields have the same name. This allows to use sort optimization and skip non-competitive documents. Not applicable for other comparators.
      Overrides:
        `setCanUsePoints` in class `FieldComparator<T extends Number>`

    - #### setTopValue

          public void setTopValue(T value)

      Description copied from class: `FieldComparator`
      Record the top value, for future calls to `LeafFieldComparator.compareTop(int)`. This is only called for searches that use searchAfter (deep paging), and is called before any calls to `FieldComparator.getLeafComparator(LeafReaderContext)`.
      Specified by:
        `setTopValue` in class `FieldComparator<T extends Number>`

    - #### setSingleSort

          public void setSingleSort()

      Description copied from class: `FieldComparator`
      Informs the comparator that sort is done on this single field. This is useful to enable some optimizations for skipping non-competitive documents.
      Overrides:
        `setSingleSort` in class `FieldComparator<T extends Number>`

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