Class DoublePoint
- java.lang.Object
-
- org.apache.lucene.document.Field
-
- org.apache.lucene.document.DoublePoint
-
- All Implemented Interfaces:
IndexableField
public final class DoublePoint extends Field
An indexeddoublefield for fast range filters. If you also need to store the value, you should add a separateStoredFieldinstance.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.
- See Also:
PointValues
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.document.Field
Field.Store
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.document.Field
fieldsData, name, tokenStream, type
-
-
Constructor Summary
Constructors Constructor Description DoublePoint(String name, double... point)Creates a new DoublePoint, indexing the provided N-dimensional double point.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static doubledecodeDimension(byte[] value, int offset)Decode single double dimensionstatic voidencodeDimension(double value, byte[] dest, int offset)Encode single double dimensionstatic QuerynewExactQuery(String field, double value)Create a query for matching an exact double value.static QuerynewRangeQuery(String field, double[] lowerValue, double[] upperValue)Create a range query for n-dimensional double values.static QuerynewRangeQuery(String field, double lowerValue, double upperValue)Create a range query for double values.static QuerynewSetQuery(String field, double... values)Create a query matching any of the specified 1D values.static QuerynewSetQuery(String field, Collection<Double> values)Create a query matching any of the specified 1D values.static doublenextDown(double d)Return the greatest double that compares less thandconsistently withDouble.compare(double, double).static doublenextUp(double d)Return the least double that compares greater thandconsistently withDouble.compare(double, double).NumbernumericValue()Non-null if this field has a numeric valuestatic BytesRefpack(double... point)Pack a double point into a BytesRefvoidsetBytesValue(BytesRef bytes)Expert: change the value of this field.voidsetDoubleValue(double value)Expert: change the value of this field.voidsetDoubleValues(double... point)Change the values of this fieldStringtoString()Prints a Field for human consumption.-
Methods inherited from class org.apache.lucene.document.Field
binaryValue, fieldType, getCharSequenceValue, invertableType, name, readerValue, setBytesValue, setByteValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, storedValue, stringValue, tokenStream, tokenStreamValue
-
-
-
-
Constructor Detail
-
DoublePoint
public DoublePoint(String name, double... point)
Creates a new DoublePoint, indexing the provided N-dimensional double point.- Parameters:
name- field namepoint- double[] value- Throws:
IllegalArgumentException- if the field name or value is null.
-
-
Method Detail
-
nextUp
public static double nextUp(double d)
Return the least double that compares greater thandconsistently withDouble.compare(double, double). The only difference withMath.nextUp(double)is that this method returns+0dwhen the argument is-0d.
-
nextDown
public static double nextDown(double d)
Return the greatest double that compares less thandconsistently withDouble.compare(double, double). The only difference withMath.nextDown(double)is that this method returns-0dwhen the argument is+0d.
-
setDoubleValue
public void setDoubleValue(double value)
Description copied from class:FieldExpert: change the value of this field. SeeField.setStringValue(String).- Overrides:
setDoubleValuein classField
-
setDoubleValues
public void setDoubleValues(double... point)
Change the values of this field
-
setBytesValue
public void setBytesValue(BytesRef bytes)
Description copied from class:FieldExpert: change the value of this field. SeeField.setStringValue(String).NOTE: the provided BytesRef is not copied so be sure not to change it until you're done with this field.
- Overrides:
setBytesValuein classField
-
numericValue
public Number numericValue()
Description copied from interface:IndexableFieldNon-null if this field has a numeric value- Specified by:
numericValuein interfaceIndexableField- Overrides:
numericValuein classField
-
pack
public static BytesRef pack(double... point)
Pack a double point into a BytesRef- Parameters:
point- double[] value- Throws:
IllegalArgumentException- is the value is null or of zero length
-
toString
public String toString()
Description copied from class:FieldPrints a Field for human consumption.
-
encodeDimension
public static void encodeDimension(double value, byte[] dest, int offset)Encode single double dimension
-
decodeDimension
public static double decodeDimension(byte[] value, int offset)Decode single double dimension
-
newExactQuery
public static Query newExactQuery(String field, double value)
Create a query for matching an exact double value.This is for simple one-dimension points, for multidimensional points use
newRangeQuery(String, double[], double[])instead.- Parameters:
field- field name. must not benull.value- double value- Returns:
- a query matching documents with this exact value
- Throws:
IllegalArgumentException- iffieldis null.
-
newRangeQuery
public static Query newRangeQuery(String field, double lowerValue, double upperValue)
Create a range query for double values.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_INFINITYorupperValue = Double.POSITIVE_INFINITY.Ranges are inclusive. For exclusive ranges, pass
nextUp(lowerValue)ornextDown(upperValue).Range comparisons are consistent with
Double.compareTo(Double).- Parameters:
field- field name. must not benull.lowerValue- lower portion of the range (inclusive).upperValue- upper portion of the range (inclusive).- Returns:
- a query matching documents within this range.
- Throws:
IllegalArgumentException- iffieldis null.
-
newRangeQuery
public static Query newRangeQuery(String field, double[] lowerValue, double[] upperValue)
Create a range query for n-dimensional double values.You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting
lowerValue[i] = Double.NEGATIVE_INFINITYorupperValue[i] = Double.POSITIVE_INFINITY.Ranges are inclusive. For exclusive ranges, pass
Math#nextUp(lowerValue[i])orMath.nextDown(upperValue[i]).Range comparisons are consistent with
Double.compareTo(Double).- Parameters:
field- field name. must not benull.lowerValue- lower portion of the range (inclusive). must not benull.upperValue- upper portion of the range (inclusive). must not benull.- Returns:
- a query matching documents within this range.
- Throws:
IllegalArgumentException- iffieldis null, iflowerValueis null, ifupperValueis null, or iflowerValue.length != upperValue.length
-
newSetQuery
public static Query newSetQuery(String field, double... values)
Create a query matching any of the specified 1D values. This is the points equivalent ofTermsQuery.- Parameters:
field- field name. must not benull.values- all values to match
-
newSetQuery
public static Query newSetQuery(String field, Collection<Double> values)
Create a query matching any of the specified 1D values. This is the points equivalent ofTermsQuery.- Parameters:
field- field name. must not benull.values- all values to match
-
-