Package org.apache.lucene.document
Class FloatField
- java.lang.Object
-
- org.apache.lucene.document.Field
-
- org.apache.lucene.document.FloatField
-
- All Implemented Interfaces:
IndexableField
public final class FloatField extends Field
Field that stores a per-documentfloatvalue for scoring, sorting or value retrieval and index the field for fast range filters. If you need more fine-grained control you can useFloatPoint,FloatDocValuesFieldandStoredField.This field defines static factory methods for creating common queries:
newExactQuery(String, float)for matching an exact 1D point.newRangeQuery(String, float, float)for matching a 1D range.newSetQuery(String, float...)for matching a 1D set.
- 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 FloatField(String name, float value)Deprecated.UseFloatField(String, float, Field.Store)withField.Store.NOinstead.FloatField(String name, float value, Field.Store stored)Creates a new FloatField, indexing the provided point, storing it as a DocValue, and optionally storing it as a stored field.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BytesRefbinaryValue()Non-null if this field has a binary valuestatic QuerynewExactQuery(String field, float value)Create a query for matching an exact float value.static QuerynewRangeQuery(String field, float lowerValue, float upperValue)Create a range query for float values.static QuerynewSetQuery(String field, float... values)Create a query matching values in a supplied setstatic SortFieldnewSortField(String field, boolean reverse, SortedNumericSelector.Type selector)Create a newSortFieldfor float values.voidsetFloatValue(float value)Expert: change the value of this field.voidsetLongValue(long value)Expert: change the value of this field.StoredValuestoredValue()Stored value.StringtoString()Prints a Field for human consumption.-
Methods inherited from class org.apache.lucene.document.Field
fieldType, getCharSequenceValue, invertableType, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setIntValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue
-
-
-
-
Constructor Detail
-
FloatField
@Deprecated public FloatField(String name, float value)
Deprecated.UseFloatField(String, float, Field.Store)withField.Store.NOinstead.Creates a new FloatField, indexing the provided point and storing it as a DocValue- Parameters:
name- field namevalue- the float value- Throws:
IllegalArgumentException- if the field name or value is null.
-
FloatField
public FloatField(String name, float value, Field.Store stored)
Creates a new FloatField, indexing the provided point, storing it as a DocValue, and optionally storing it as a stored field.- Parameters:
name- field namevalue- the float valuestored- whether to store the field- Throws:
IllegalArgumentException- if the field name or value is null.
-
-
Method Detail
-
binaryValue
public BytesRef binaryValue()
Description copied from interface:IndexableFieldNon-null if this field has a binary value- Specified by:
binaryValuein interfaceIndexableField- Overrides:
binaryValuein classField
-
storedValue
public StoredValue 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
public String toString()
Description copied from class:FieldPrints a Field for human consumption.
-
setFloatValue
public void setFloatValue(float value)
Description copied from class:FieldExpert: change the value of this field. SeeField.setStringValue(String).- Overrides:
setFloatValuein 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
public static Query newExactQuery(String field, float value)
Create a query for matching an exact float 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
public static Query newRangeQuery(String field, float lowerValue, float upperValue)
Create a range query for float values.You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting
lowerValue = Float.NEGATIVE_INFINITYorupperValue = Float.POSITIVE_INFINITY.Range comparisons are consistent with
Float.compareTo(Float).- 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
public static Query newSetQuery(String field, float... values)
Create a query matching values in a supplied set- Parameters:
field- field name. must not benull.values- float 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 float 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.
-
-