org.apache.lucene.document

Class FloatPoint

    • Constructor Detail

      • FloatPoint

        public FloatPoint(String name,
                          float... point)
        Creates a new FloatPoint, indexing the provided N-dimensional float point.
        Parameters:
        name - field name
        point - float[] value
        Throws:
        IllegalArgumentException - if the field name or value is null.
    • Method Detail

      • setFloatValues

        public void setFloatValues(float... point)
        Change the values of this field
      • encodeDimension

        public static void encodeDimension(float value,
                                           byte[] dest,
                                           int offset)
        Encode single float dimension
      • decodeDimension

        public static float decodeDimension(byte[] value,
                                            int offset)
        Decode single float dimension
      • newRangeQuery

        public static Query newRangeQuery(String field,
                                          float lowerValue,
                                          float upperValue)
        Create a range query for float values.

        This is for simple one-dimension ranges, for multidimensional ranges use newRangeQuery(String, float[], float[]) instead.

        You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting lowerValue = Float.NEGATIVE_INFINITY or upperValue = Float.POSITIVE_INFINITY.

        Ranges are inclusive. For exclusive ranges, pass nextUp(lowerValue) or nextDown(upperValue).

        Range comparisons are consistent with Float.compareTo(Float).

        Parameters:
        field - field name. must not be null.
        lowerValue - lower portion of the range (inclusive).
        upperValue - upper portion of the range (inclusive).
        Returns:
        a query matching documents within this range.
        Throws:
        IllegalArgumentException - if field is null.
      • newRangeQuery

        public static Query newRangeQuery(String field,
                                          float[] lowerValue,
                                          float[] upperValue)
        Create a range query for n-dimensional float values.

        You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting lowerValue[i] = Float.NEGATIVE_INFINITY or upperValue[i] = Float.POSITIVE_INFINITY.

        Ranges are inclusive. For exclusive ranges, pass Math#nextUp(lowerValue[i]) or Math.nextDown(upperValue[i]).

        Range comparisons are consistent with Float.compareTo(Float).

        Parameters:
        field - field name. must not be null.
        lowerValue - lower portion of the range (inclusive). must not be null.
        upperValue - upper portion of the range (inclusive). must not be null.
        Returns:
        a query matching documents within this range.
        Throws:
        IllegalArgumentException - if field is null, if lowerValue is null, if upperValue is null, or if lowerValue.length != upperValue.length
      • newSetQuery

        public static Query newSetQuery(String field,
                                        float... values)
        Create a query matching any of the specified 1D values. This is the points equivalent of TermsQuery.
        Parameters:
        field - field name. must not be null.
        values - all values to match
      • newSetQuery

        public static Query newSetQuery(String field,
                                        Collection<Float> values)
        Create a query matching any of the specified 1D values. This is the points equivalent of TermsQuery.
        Parameters:
        field - field name. must not be null.
        values - all values to match