org.apache.lucene.document

## Class FloatRange

- java.lang.Object
- - org.apache.lucene.document.Field
  - - org.apache.lucene.document.FloatRange

- All Implemented Interfaces:
    IndexableField

      public class FloatRange
      extends Field

  An indexed Float Range field.

  This field indexes dimensional ranges defined as min/max pairs. It supports up to a maximum of 4 dimensions (indexed as 8 numeric values). With 1 dimension representing a single float range, 2 dimensions representing a bounding box, 3 dimensions a bounding cube, and 4 dimensions a tesseract.

  Multiple values for the same field in one document is supported, and open ended ranges can be defined using `Float.NEGATIVE_INFINITY` and `Float.POSITIVE_INFINITY`.

  This field defines the following static factory methods for common search operations over float ranges:

  - `newIntersectsQuery()` matches ranges that intersect the defined search range.
  - `newWithinQuery()` matches ranges that are within the defined search range.
  - `newContainsQuery()` matches ranges that contain the defined search range.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.document.Field

      `Field.Store`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `BYTES` stores float values so number of bytes is 4

    - ### Fields inherited from class org.apache.lucene.document.Field

      `fieldsData, name, tokenStream, type`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FloatRange(String name, float[] min, float[] max)` Create a new FloatRange type, from min/max parallel arrays

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `float` | `getMax(int dimension)` Get the max value for the given dimension
    `float` | `getMin(int dimension)` Get the min value for the given dimension
    `static Query` | `newContainsQuery(String field, float[] min, float[] max)` Create a query for matching indexed float ranges that contain the defined range.
    `static Query` | `newCrossesQuery(String field, float[] min, float[] max)` Create a query for matching indexed ranges that cross the defined range.
    `static Query` | `newIntersectsQuery(String field, float[] min, float[] max)` Create a query for matching indexed ranges that intersect the defined range.
    `static Query` | `newWithinQuery(String field, float[] min, float[] max)` Create a query for matching indexed ranges that are within the defined range.
    `void` | `setRangeValues(float[] min, float[] max)` Changes the values of the field.
    `String` | `toString()` Prints a Field for human consumption.

    - ### Methods inherited from class org.apache.lucene.document.Field

      `binaryValue, fieldType, getCharSequenceValue, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue`

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

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

- - ### Field Detail

    - #### BYTES

          public static final int BYTES

      stores float values so number of bytes is 4
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### FloatRange

          public FloatRange(String name,
                            float[] min,
                            float[] max)

      Create a new FloatRange type, from min/max parallel arrays
      Parameters:
        `name` - field name. must not be null.
        `min` - range min values; each entry is the min value for the dimension
        `max` - range max values; each entry is the max value for the dimension

  - ### Method Detail

    - #### setRangeValues

          public void setRangeValues(float[] min,
                                     float[] max)

      Changes the values of the field.
      Parameters:
        `min` - array of min values. (accepts `Float.NEGATIVE_INFINITY`)
        `max` - array of max values. (accepts `Float.POSITIVE_INFINITY`)
      Throws:
        `IllegalArgumentException` - if `min` or `max` is invalid

    - #### getMin

          public float getMin(int dimension)

      Get the min value for the given dimension
      Parameters:
        `dimension` - the dimension, always positive
      Returns:
        the decoded min value

    - #### getMax

          public float getMax(int dimension)

      Get the max value for the given dimension
      Parameters:
        `dimension` - the dimension, always positive
      Returns:
        the decoded max value

    - #### newIntersectsQuery

          public static Query newIntersectsQuery(String field,
                                                 float[] min,
                                                 float[] max)

      Create a query for matching indexed ranges that intersect the defined range.
      Parameters:
        `field` - field name. must not be null.
        `min` - array of min values. (accepts `Float.NEGATIVE_INFINITY`)
        `max` - array of max values. (accepts `Float.MAX_VALUE`)
      Returns:
        query for matching intersecting ranges (overlap, within, or contains)
      Throws:
        `IllegalArgumentException` - if `field` is null, `min` or `max` is invalid

    - #### newContainsQuery

          public static Query newContainsQuery(String field,
                                               float[] min,
                                               float[] max)

      Create a query for matching indexed float ranges that contain the defined range.
      Parameters:
        `field` - field name. must not be null.
        `min` - array of min values. (accepts `Float.NEGATIVE_INFINITY`)
        `max` - array of max values. (accepts `Float.POSITIVE_INFINITY`)
      Returns:
        query for matching ranges that contain the defined range
      Throws:
        `IllegalArgumentException` - if `field` is null, `min` or `max` is invalid

    - #### newWithinQuery

          public static Query newWithinQuery(String field,
                                             float[] min,
                                             float[] max)

      Create a query for matching indexed ranges that are within the defined range.
      Parameters:
        `field` - field name. must not be null.
        `min` - array of min values. (accepts `Float.NEGATIVE_INFINITY`)
        `max` - array of max values. (accepts `Float.POSITIVE_INFINITY`)
      Returns:
        query for matching ranges within the defined range
      Throws:
        `IllegalArgumentException` - if `field` is null, `min` or `max` is invalid

    - #### newCrossesQuery

          public static Query newCrossesQuery(String field,
                                              float[] min,
                                              float[] max)

      Create a query for matching indexed ranges that cross the defined range. A CROSSES is defined as any set of ranges that are not disjoint and not wholly contained by the query. Effectively, its the complement of union(WITHIN, DISJOINT).
      Parameters:
        `field` - field name. must not be null.
        `min` - array of min values. (accepts `Float.NEGATIVE_INFINITY`)
        `max` - array of max values. (accepts `Float.POSITIVE_INFINITY`)
      Returns:
        query for matching ranges within the defined range
      Throws:
        `IllegalArgumentException` - if `field` is null, `min` or `max` is invalid

    - #### toString

          public String toString()

      Description copied from class: `Field`
      Prints a Field for human consumption.
      Overrides:
        `toString` in class `Field`

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