org.apache.lucene.search

## Class NumericRangeFilter

- java.lang.Object
- - org.apache.lucene.search.Filter
  - - org.apache.lucene.search.MultiTermQueryWrapperFilter
    - - org.apache.lucene.search.NumericRangeFilter

- All Implemented Interfaces:
    java.io.Serializable

      public final class NumericRangeFilter
      extends MultiTermQueryWrapperFilter

  A `Filter` that only accepts numeric values within a specified range. To use this, you must first index the numeric values using `NumericField` (expert: `NumericTokenStream`).

  You create a new NumericRangeFilter with the static factory methods, eg:

       Filter f = NumericRangeFilter.newFloatRange("weight",
                                                   new Float(0.3f), new Float(0.10f),
                                                   true, true);

  accepts all documents whose float valued "weight" field ranges from 0.3 to 0.10, inclusive. See `NumericRangeQuery` for details on how Lucene indexes and searches numeric valued fields.

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

  Since:
    2.9
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.search.MultiTermQueryWrapperFilter

      `query`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getField()` Returns the field name for this filter
    `java.lang.Number` | `getMax()` Returns the upper value of this range filter
    `java.lang.Number` | `getMin()` Returns the lower value of this range filter
    `boolean` | `includesMax()` Returns `true` if the upper endpoint is inclusive
    `boolean` | `includesMin()` Returns `true` if the lower endpoint is inclusive
    `static NumericRangeFilter` | `newDoubleRange(java.lang.String field, java.lang.Double min, java.lang.Double max, boolean minInclusive, boolean maxInclusive)` Factory that creates a `NumericRangeFilter`, that queries a `double` range using the default `precisionStep` `NumericUtils.PRECISION_STEP_DEFAULT` (4).
    `static NumericRangeFilter` | `newDoubleRange(java.lang.String field, int precisionStep, java.lang.Double min, java.lang.Double max, boolean minInclusive, boolean maxInclusive)` Factory that creates a `NumericRangeFilter`, that filters a `double` range using the given `precisionStep`.
    `static NumericRangeFilter` | `newFloatRange(java.lang.String field, java.lang.Float min, java.lang.Float max, boolean minInclusive, boolean maxInclusive)` Factory that creates a `NumericRangeFilter`, that queries a `float` range using the default `precisionStep` `NumericUtils.PRECISION_STEP_DEFAULT` (4).
    `static NumericRangeFilter` | `newFloatRange(java.lang.String field, int precisionStep, java.lang.Float min, java.lang.Float max, boolean minInclusive, boolean maxInclusive)` Factory that creates a `NumericRangeFilter`, that filters a `float` range using the given `precisionStep`.
    `static NumericRangeFilter` | `newIntRange(java.lang.String field, java.lang.Integer min, java.lang.Integer max, boolean minInclusive, boolean maxInclusive)` Factory that creates a `NumericRangeFilter`, that queries a `int` range using the default `precisionStep` `NumericUtils.PRECISION_STEP_DEFAULT` (4).
    `static NumericRangeFilter` | `newIntRange(java.lang.String field, int precisionStep, java.lang.Integer min, java.lang.Integer max, boolean minInclusive, boolean maxInclusive)` Factory that creates a `NumericRangeFilter`, that filters a `int` range using the given `precisionStep`.
    `static NumericRangeFilter` | `newLongRange(java.lang.String field, int precisionStep, java.lang.Long min, java.lang.Long max, boolean minInclusive, boolean maxInclusive)` Factory that creates a `NumericRangeFilter`, that filters a `long` range using the given `precisionStep`.
    `static NumericRangeFilter` | `newLongRange(java.lang.String field, java.lang.Long min, java.lang.Long max, boolean minInclusive, boolean maxInclusive)` Factory that creates a `NumericRangeFilter`, that queries a `long` range using the default `precisionStep` `NumericUtils.PRECISION_STEP_DEFAULT` (4).

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

      `bits, clearTotalNumberOfTerms, equals, getDocIdSet, getTotalNumberOfTerms, hashCode, toString`

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

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

- - ### Method Detail

    - #### newLongRange

          public static NumericRangeFilter newLongRange(java.lang.String field,
                                                        int precisionStep,
                                                        java.lang.Long min,
                                                        java.lang.Long max,
                                                        boolean minInclusive,
                                                        boolean maxInclusive)

      Factory that creates a `NumericRangeFilter`, that filters a `long` range using the given `precisionStep`. You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value to `null`. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.

    - #### newLongRange

          public static NumericRangeFilter newLongRange(java.lang.String field,
                                                        java.lang.Long min,
                                                        java.lang.Long max,
                                                        boolean minInclusive,
                                                        boolean maxInclusive)

      Factory that creates a `NumericRangeFilter`, that queries a `long` range using the default `precisionStep` `NumericUtils.PRECISION_STEP_DEFAULT` (4). You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value to `null`. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.

    - #### newIntRange

          public static NumericRangeFilter newIntRange(java.lang.String field,
                                                       int precisionStep,
                                                       java.lang.Integer min,
                                                       java.lang.Integer max,
                                                       boolean minInclusive,
                                                       boolean maxInclusive)

      Factory that creates a `NumericRangeFilter`, that filters a `int` range using the given `precisionStep`. You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value to `null`. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.

    - #### newIntRange

          public static NumericRangeFilter newIntRange(java.lang.String field,
                                                       java.lang.Integer min,
                                                       java.lang.Integer max,
                                                       boolean minInclusive,
                                                       boolean maxInclusive)

      Factory that creates a `NumericRangeFilter`, that queries a `int` range using the default `precisionStep` `NumericUtils.PRECISION_STEP_DEFAULT` (4). You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value to `null`. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.

    - #### newDoubleRange

          public static NumericRangeFilter newDoubleRange(java.lang.String field,
                                                          int precisionStep,
                                                          java.lang.Double min,
                                                          java.lang.Double max,
                                                          boolean minInclusive,
                                                          boolean maxInclusive)

      Factory that creates a `NumericRangeFilter`, that filters a `double` range using the given `precisionStep`. You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value to `null`. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.

    - #### newDoubleRange

          public static NumericRangeFilter newDoubleRange(java.lang.String field,
                                                          java.lang.Double min,
                                                          java.lang.Double max,
                                                          boolean minInclusive,
                                                          boolean maxInclusive)

      Factory that creates a `NumericRangeFilter`, that queries a `double` range using the default `precisionStep` `NumericUtils.PRECISION_STEP_DEFAULT` (4). You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value to `null`. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.

    - #### newFloatRange

          public static NumericRangeFilter newFloatRange(java.lang.String field,
                                                         int precisionStep,
                                                         java.lang.Float min,
                                                         java.lang.Float max,
                                                         boolean minInclusive,
                                                         boolean maxInclusive)

      Factory that creates a `NumericRangeFilter`, that filters a `float` range using the given `precisionStep`. You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value to `null`. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.

    - #### newFloatRange

          public static NumericRangeFilter newFloatRange(java.lang.String field,
                                                         java.lang.Float min,
                                                         java.lang.Float max,
                                                         boolean minInclusive,
                                                         boolean maxInclusive)

      Factory that creates a `NumericRangeFilter`, that queries a `float` range using the default `precisionStep` `NumericUtils.PRECISION_STEP_DEFAULT` (4). You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value to `null`. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.

    - #### getField

          public java.lang.String getField()

      Returns the field name for this filter

    - #### includesMin

          public boolean includesMin()

      Returns `true` if the lower endpoint is inclusive

    - #### includesMax

          public boolean includesMax()

      Returns `true` if the upper endpoint is inclusive

    - #### getMin

          public java.lang.Number getMin()

      Returns the lower value of this range filter

    - #### getMax

          public java.lang.Number getMax()

      Returns the upper value of this range filter

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