org.apache.lucene.search

## Class DocValuesRangeFilter<T>

- java.lang.Object
- - org.apache.lucene.search.Query
  - - org.apache.lucene.search.Filter
    - - org.apache.lucene.search.DocValuesRangeFilter<T>

- All Implemented Interfaces:
    Cloneable

  Deprecated.
  Use `DocValuesRangeQuery` instead

      @Deprecated
      public abstract class DocValuesRangeFilter<T>
      extends Filter

  A range filter built on top of numeric doc values field (from `LeafReader.getNumericDocValues(String)`).

  `DocValuesRangeFilter` builds a single cache for the field the first time it is used. Each subsequent `DocValuesRangeFilter` on the same field then reuses this cache, even if the range itself changes.

  This means that `DocValuesRangeFilter` is much faster (sometimes more than 100x as fast) as building a `TermRangeFilter`, if using a `newStringRange(java.lang.String, java.lang.String, java.lang.String, boolean, boolean)`. However, if the range never changes it is slower (around 2x as slow) than building a CachingWrapperFilter on top of a single `TermRangeFilter`. For numeric data types, this filter may be significantly faster than `NumericRangeFilter`. Furthermore, it does not need the numeric values encoded by `IntField`, `FloatField`, `LongField` or `DoubleField`. But it has the problem that it only works with exact one value/document (see below).

  As with all `LeafReader.getNumericDocValues(java.lang.String)` based functionality, `DocValuesRangeFilter` is only valid for fields which exact one term for each document (except for `newStringRange(java.lang.String, java.lang.String, java.lang.String, boolean, boolean)` where 0 terms are also allowed). Due to historical reasons, for numeric ranges all terms that do not have a numeric value, 0 is assumed.

  Thus it works on dates, prices and other single value fields but will not work on regular text fields. It is preferable to use a `NOT_ANALYZED` field to ensure that there is only a single term.

  This class does not have an constructor, use one of the static factory methods available, that create a correct instance for different data types.

  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)` Deprecated.
    `abstract DocIdSet` | `getDocIdSet(LeafReaderContext context, Bits acceptDocs)` Deprecated. This method is implemented for each data type
    `String` | `getField()` Deprecated. Returns the field name for this filter
    `T` | `getLowerVal()` Deprecated. Returns the lower value of this range filter
    `T` | `getUpperVal()` Deprecated. Returns the upper value of this range filter
    `int` | `hashCode()` Deprecated.
    `boolean` | `includesLower()` Deprecated. Returns `true` if the lower endpoint is inclusive
    `boolean` | `includesUpper()` Deprecated. Returns `true` if the upper endpoint is inclusive
    `static DocValuesRangeFilter<BytesRef>` | `newBytesRefRange(String field, BytesRef lowerVal, BytesRef upperVal, boolean includeLower, boolean includeUpper)` Deprecated. Creates a BytesRef range filter using `LeafReader.getSortedDocValues(String)`.
    `static DocValuesRangeFilter<Double>` | `newDoubleRange(String field, Double lowerVal, Double upperVal, boolean includeLower, boolean includeUpper)` Deprecated. Creates a numeric range filter using `LeafReader.getNumericDocValues(String)`.
    `static DocValuesRangeFilter<Float>` | `newFloatRange(String field, Float lowerVal, Float upperVal, boolean includeLower, boolean includeUpper)` Deprecated. Creates a numeric range filter using `LeafReader.getNumericDocValues(String)`.
    `static DocValuesRangeFilter<Integer>` | `newIntRange(String field, Integer lowerVal, Integer upperVal, boolean includeLower, boolean includeUpper)` Deprecated. Creates a numeric range filter using `LeafReader.getSortedDocValues(String)`.
    `static DocValuesRangeFilter<Long>` | `newLongRange(String field, Long lowerVal, Long upperVal, boolean includeLower, boolean includeUpper)` Deprecated. Creates a numeric range filter using `LeafReader.getNumericDocValues(String)`.
    `static DocValuesRangeFilter<String>` | `newStringRange(String field, String lowerVal, String upperVal, boolean includeLower, boolean includeUpper)` Deprecated. Creates a string range filter using `LeafReader.getSortedDocValues(String)`.
    `String` | `toString(String defaultField)` Deprecated.

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

      `rewrite`

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

      `clone, createWeight, getBoost, setBoost, toString`

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

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

- - ### Method Detail

    - #### getDocIdSet

          public abstract DocIdSet getDocIdSet(LeafReaderContext context,
                             Bits acceptDocs)
                                        throws IOException

      Deprecated.
      This method is implemented for each data type
      Specified by:
        `getDocIdSet` in class `Filter`
      Throws:
        `IOException`

    - #### newStringRange

          public static DocValuesRangeFilter<String> newStringRange(String field,
                                                    String lowerVal,
                                                    String upperVal,
                                                    boolean includeLower,
                                                    boolean includeUpper)

      Deprecated.
      Creates a string range filter using `LeafReader.getSortedDocValues(String)`. This works with all fields containing zero or one term in the field. The range can be half-open by setting one of the values to `null`.

    - #### newBytesRefRange

          public static DocValuesRangeFilter<BytesRef> newBytesRefRange(String field,
                                                        BytesRef lowerVal,
                                                        BytesRef upperVal,
                                                        boolean includeLower,
                                                        boolean includeUpper)

      Deprecated.
      Creates a BytesRef range filter using `LeafReader.getSortedDocValues(String)`. This works with all fields containing zero or one term in the field. The range can be half-open by setting one of the values to `null`.

    - #### newIntRange

          public static DocValuesRangeFilter<Integer> newIntRange(String field,
                                                  Integer lowerVal,
                                                  Integer upperVal,
                                                  boolean includeLower,
                                                  boolean includeUpper)

      Deprecated.
      Creates a numeric range filter using `LeafReader.getSortedDocValues(String)`. This works with all int fields containing exactly one numeric term in the field. The range can be half-open by setting one of the values to `null`.

    - #### newLongRange

          public static DocValuesRangeFilter<Long> newLongRange(String field,
                                                Long lowerVal,
                                                Long upperVal,
                                                boolean includeLower,
                                                boolean includeUpper)

      Deprecated.
      Creates a numeric range filter using `LeafReader.getNumericDocValues(String)`. This works with all long fields containing exactly one numeric term in the field. The range can be half-open by setting one of the values to `null`.

    - #### newFloatRange

          public static DocValuesRangeFilter<Float> newFloatRange(String field,
                                                  Float lowerVal,
                                                  Float upperVal,
                                                  boolean includeLower,
                                                  boolean includeUpper)

      Deprecated.
      Creates a numeric range filter using `LeafReader.getNumericDocValues(String)`. This works with all float fields containing exactly one numeric term in the field. The range can be half-open by setting one of the values to `null`.

    - #### newDoubleRange

          public static DocValuesRangeFilter<Double> newDoubleRange(String field,
                                                    Double lowerVal,
                                                    Double upperVal,
                                                    boolean includeLower,
                                                    boolean includeUpper)

      Deprecated.
      Creates a numeric range filter using `LeafReader.getNumericDocValues(String)`. This works with all double fields containing exactly one numeric term in the field. The range can be half-open by setting one of the values to `null`.

    - #### toString

          public final String toString(String defaultField)

      Deprecated.
      Specified by:
        `toString` in class `Query`

    - #### equals

          public final boolean equals(Object o)

      Deprecated.
      Overrides:
        `equals` in class `Query`

    - #### hashCode

          public final int hashCode()

      Deprecated.
      Overrides:
        `hashCode` in class `Query`

    - #### getField

          public String getField()

      Deprecated.
      Returns the field name for this filter

    - #### includesLower

          public boolean includesLower()

      Deprecated.
      Returns `true` if the lower endpoint is inclusive

    - #### includesUpper

          public boolean includesUpper()

      Deprecated.
      Returns `true` if the upper endpoint is inclusive

    - #### getLowerVal

          public T getLowerVal()

      Deprecated.
      Returns the lower value of this range filter

    - #### getUpperVal

          public T getUpperVal()

      Deprecated.
      Returns the upper value of this range filter

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