Package org.apache.lucene.document
Class DoubleField
java.lang.Object
org.apache.lucene.document.Field
org.apache.lucene.document.DoubleField
- All Implemented Interfaces:
IndexableField
Field that stores a per-document
double value for scoring, sorting or value
retrieval and index the field for fast range filters. If you need more fine-grained control you
can use DoublePoint, DoubleDocValuesField and StoredField.
This field defines static factory methods for creating common queries:
newExactQuery(String, double)for matching an exact 1D point.newRangeQuery(String, double, double)for matching a 1D range.newSetQuery(String, double...)for matching a 1D set.
- See Also:
-
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, type -
Constructor Summary
ConstructorsConstructorDescriptionDoubleField(String name, double value, Field.Store stored) Creates a new DoubleField, indexing the provided point, storing it as a DocValue, and optionally storing it as a stored field. -
Method Summary
Modifier and TypeMethodDescriptionNon-null if this field has a binary valuestatic 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 double values.static QuerynewSetQuery(String field, double... values) Create a query matching values in a supplied setstatic SortFieldnewSortField(String field, boolean reverse, SortedNumericSelector.Type selector) Create a newSortFieldfor double values.voidsetDoubleValue(double value) Expert: change the value of this field.voidsetLongValue(long value) Expert: change the value of this field.Stored value.toString()Prints a Field for human consumption.Methods inherited from class org.apache.lucene.document.Field
fieldType, getCharSequenceValue, invertableType, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setFloatValue, setIntValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue
-
Constructor Details
-
DoubleField
Creates a new DoubleField, indexing the provided point, storing it as a DocValue, and optionally storing it as a stored field.- Parameters:
name- field namevalue- the double valuestored- whether to store the field- Throws:
IllegalArgumentException- if the field name or value is null.
-
-
Method Details
-
binaryValue
Description copied from interface:IndexableFieldNon-null if this field has a binary value- Specified by:
binaryValuein interfaceIndexableField- Overrides:
binaryValuein classField
-
storedValue
Description copied from interface:IndexableFieldStored value. This method is called to populate stored fields and must return a non-null value if the field stored.- Specified by:
storedValuein interfaceIndexableField- Overrides:
storedValuein classField
-
toString
Description copied from class:FieldPrints a Field for human consumption. -
setDoubleValue
public void setDoubleValue(double value) Description copied from class:FieldExpert: change the value of this field. SeeField.setStringValue(String).- Overrides:
setDoubleValuein classField
-
setLongValue
public void setLongValue(long value) Description copied from class:FieldExpert: change the value of this field. SeeField.setStringValue(String).- Overrides:
setLongValuein classField
-
newExactQuery
Create a query for matching an exact double value.- Parameters:
field- field name. must not benull.value- exact value- Returns:
- a query matching documents with this exact value
- Throws:
IllegalArgumentException- iffieldis null.
-
newRangeQuery
Create a range query for double values.You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting
lowerValue = Double.NEGATIVE_INFINITYorupperValue = Double.POSITIVE_INFINITY.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.
-
newSetQuery
Create a query matching values in a supplied set- Parameters:
field- field name. must not benull.values- double values- Returns:
- a query matching documents within this set.
- Throws:
IllegalArgumentException- iffieldis null.
-
newSortField
public static SortField newSortField(String field, boolean reverse, SortedNumericSelector.Type selector) Create a newSortFieldfor double values.- Parameters:
field- field name. must not benull.reverse- true if natural order should be reversed.selector- custom selector type for choosing the sort value from the set.
-