public final class DoublePoint extends Field
double field for fast range filters. If you also
need to store the value, you should add a separate StoredField instance.
Finding all documents within an N-dimensional shape or range at search time is efficient. Multiple values for the same field in one document is allowed.
This field defines static factory methods for creating common queries:
newExactQuery(String, double) for matching an exact 1D point.
newSetQuery(String, double...) for matching a set of 1D values.
newRangeQuery(String, double, double) for matching a 1D range.
newRangeQuery(String, double[], double[]) for matching points/ranges in n-dimensional space.
PointValuesField.StorefieldsData, name, tokenStream, type| Constructor and Description |
|---|
DoublePoint(String name,
double... point)
Creates a new DoublePoint, indexing the
provided N-dimensional double point.
|
| Modifier and Type | Method and Description |
|---|---|
static double |
decodeDimension(byte[] value,
int offset)
Decode single double dimension
|
static void |
encodeDimension(double value,
byte[] dest,
int offset)
Encode single double dimension
|
static Query |
newExactQuery(String field,
double value)
Create a query for matching an exact double value.
|
static Query |
newRangeQuery(String field,
double[] lowerValue,
double[] upperValue)
Create a range query for n-dimensional double values.
|
static Query |
newRangeQuery(String field,
double lowerValue,
double upperValue)
Create a range query for double values.
|
static Query |
newSetQuery(String field,
Collection<Double> values)
Create a query matching any of the specified 1D values.
|
static Query |
newSetQuery(String field,
double... values)
Create a query matching any of the specified 1D values.
|
static double |
nextDown(double d)
Return the greatest double that compares less than
d consistently
with Double.compare(double, double). |
static double |
nextUp(double d)
Return the least double that compares greater than
d consistently
with Double.compare(double, double). |
Number |
numericValue()
Non-null if this field has a numeric value
|
static BytesRef |
pack(double... point)
Pack a double point into a BytesRef
|
void |
setBytesValue(BytesRef bytes)
Expert: change the value of this field.
|
void |
setDoubleValue(double value)
Expert: change the value of this field.
|
void |
setDoubleValues(double... point)
Change the values of this field
|
String |
toString()
Prints a Field for human consumption.
|
binaryValue, fieldType, getCharSequenceValue, name, readerValue, setBytesValue, setByteValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValuepublic DoublePoint(String name, double... point)
name - field namepoint - double[] valueIllegalArgumentException - if the field name or value is null.public static double nextUp(double d)
d consistently
with Double.compare(double, double). The only difference with
Math.nextUp(double) is that this method returns +0d when
the argument is -0d.public static double nextDown(double d)
d consistently
with Double.compare(double, double). The only difference with
Math.nextDown(double) is that this method returns -0d when
the argument is +0d.public void setDoubleValue(double value)
FieldField.setStringValue(String).setDoubleValue in class Fieldpublic void setDoubleValues(double... point)
public void setBytesValue(BytesRef bytes)
FieldField.setStringValue(String).
NOTE: the provided BytesRef is not copied so be sure not to change it until you're done with this field.
setBytesValue in class Fieldpublic Number numericValue()
IndexableFieldnumericValue in interface IndexableFieldnumericValue in class Fieldpublic static BytesRef pack(double... point)
point - double[] valueIllegalArgumentException - is the value is null or of zero lengthpublic String toString()
Fieldpublic static void encodeDimension(double value,
byte[] dest,
int offset)
public static double decodeDimension(byte[] value,
int offset)
public static Query newExactQuery(String field, double value)
This is for simple one-dimension points, for multidimensional points use
newRangeQuery(String, double[], double[]) instead.
field - field name. must not be null.value - double valueIllegalArgumentException - if field is null.public static Query newRangeQuery(String field, double lowerValue, double upperValue)
This is for simple one-dimension ranges, for multidimensional ranges use
newRangeQuery(String, double[], double[]) instead.
You can have half-open ranges (which are in fact </≤ or >/≥ queries)
by setting lowerValue = Double.NEGATIVE_INFINITY or upperValue = Double.POSITIVE_INFINITY.
Ranges are inclusive. For exclusive ranges, pass nextUp(lowerValue)
or nextDown(upperValue).
Range comparisons are consistent with Double.compareTo(Double).
field - field name. must not be null.lowerValue - lower portion of the range (inclusive).upperValue - upper portion of the range (inclusive).IllegalArgumentException - if field is null.public static Query newRangeQuery(String field, double[] lowerValue, double[] upperValue)
You can have half-open ranges (which are in fact </≤ or >/≥ queries)
by setting lowerValue[i] = Double.NEGATIVE_INFINITY or upperValue[i] = Double.POSITIVE_INFINITY.
Ranges are inclusive. For exclusive ranges, pass Math#nextUp(lowerValue[i])
or Math.nextDown(upperValue[i]).
Range comparisons are consistent with Double.compareTo(Double).
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.IllegalArgumentException - if field is null, if lowerValue is null, if upperValue is null,
or if lowerValue.length != upperValue.lengthpublic static Query newSetQuery(String field, double... values)
TermsQuery.field - field name. must not be null.values - all values to matchpublic static Query newSetQuery(String field, Collection<Double> values)
TermsQuery.field - field name. must not be null.values - all values to matchCopyright © 2000-2020 Apache Software Foundation. All Rights Reserved.