Class NumericDocValuesField
- java.lang.Object
-
- org.apache.lucene.document.Field
-
- org.apache.lucene.document.NumericDocValuesField
-
- All Implemented Interfaces:
IndexableField
- Direct Known Subclasses:
DoubleDocValuesField,FloatDocValuesField
public class NumericDocValuesField extends Field
Field that stores a per-documentlongvalue for scoring, sorting or value retrieval. Here's an example usage:document.add(new NumericDocValuesField(name, 22L));
If you also need to store the value, you should add a separate
StoredFieldinstance.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.document.Field
Field.Store
-
-
Field Summary
Fields Modifier and Type Field Description static FieldTypeTYPEType for numeric DocValues.-
Fields inherited from class org.apache.lucene.document.Field
fieldsData, name, tokenStream, type
-
-
Constructor Summary
Constructors Constructor Description NumericDocValuesField(String name, long value)Creates a new DocValues field with the specified 64-bit long valueNumericDocValuesField(String name, Long value)Creates a new DocValues field with the specified 64-bit long value
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static QuerynewSlowExactQuery(String field, long value)Create a query for matching an exact long value.static QuerynewSlowRangeQuery(String field, long lowerValue, long upperValue)Create a range query that matches all documents whose value is betweenlowerValueandupperValueincluded.static QuerynewSlowSetQuery(String field, long... values)Create a query matching any of the specified values.-
Methods inherited from class org.apache.lucene.document.Field
binaryValue, fieldType, getCharSequenceValue, invertableType, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, storedValue, stringValue, tokenStream, tokenStreamValue, toString
-
-
-
-
Field Detail
-
TYPE
public static final FieldType TYPE
Type for numeric DocValues.
-
-
Constructor Detail
-
NumericDocValuesField
public NumericDocValuesField(String name, long value)
Creates a new DocValues field with the specified 64-bit long value- Parameters:
name- field namevalue- 64-bit long value- Throws:
IllegalArgumentException- if the field name is null
-
NumericDocValuesField
public NumericDocValuesField(String name, Long value)
Creates a new DocValues field with the specified 64-bit long value- Parameters:
name- field namevalue- 64-bit long value ornullif the existing fields value should be removed on update- Throws:
IllegalArgumentException- if the field name is null
-
-
Method Detail
-
newSlowRangeQuery
public static Query newSlowRangeQuery(String field, long lowerValue, long upperValue)
Create a range query that matches all documents whose value is betweenlowerValueandupperValueincluded.You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting
lowerValue = Long.MIN_VALUEorupperValue = Long.MAX_VALUE.Ranges are inclusive. For exclusive ranges, pass
Math.addExact(lowerValue, 1)orMath.addExact(upperValue, -1).NOTE: Such queries cannot efficiently advance to the next match, which makes them slow if they are not ANDed with a selective query. As a consequence, they are best used wrapped in an
IndexOrDocValuesQuery, alongside a range query that executes on points, such asLongPoint.newRangeQuery(java.lang.String, long, long).
-
newSlowSetQuery
public static Query newSlowSetQuery(String field, long... values)
Create a query matching any of the specified values.NOTE: Such queries cannot efficiently advance to the next match, which makes them slow if they are not ANDed with a selective query. As a consequence, they are best used wrapped in an
IndexOrDocValuesQuery, alongside a set query that executes on points, such asLongPoint.newSetQuery(java.lang.String, long...).
-
newSlowExactQuery
public static Query newSlowExactQuery(String field, long value)
Create a query for matching an exact long value.NOTE: Such queries cannot efficiently advance to the next match, which makes them slow if they are not ANDed with a selective query. As a consequence, they are best used wrapped in an
IndexOrDocValuesQuery, alongside a range query that executes on points, such asLongPoint.newExactQuery(java.lang.String, long).
-
-