public class NumericDocValuesField extends Field
Field that stores a per-document long
value 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 StoredField
instance.
Field.Store
Modifier and Type | Field and Description |
---|---|
static FieldType |
TYPE
Type for numeric DocValues.
|
fieldsData, name, tokenStream, type
Constructor and Description |
---|
NumericDocValuesField(String name,
long value)
Creates a new DocValues field with the specified 64-bit long value
|
NumericDocValuesField(String name,
Long value)
Creates a new DocValues field with the specified 64-bit long value
|
Modifier and Type | Method and Description |
---|---|
static Query |
newSlowExactQuery(String field,
long value)
Create a query for matching an exact long value.
|
static Query |
newSlowRangeQuery(String field,
long lowerValue,
long upperValue)
Create a range query that matches all documents whose value is between
lowerValue and upperValue included. |
binaryValue, fieldType, getCharSequenceValue, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue, toString
public static final FieldType TYPE
public NumericDocValuesField(String name, long value)
name
- field namevalue
- 64-bit long valueIllegalArgumentException
- if the field name is nullpublic NumericDocValuesField(String name, Long value)
name
- field namevalue
- 64-bit long value or null
if the existing fields value should be removed on updateIllegalArgumentException
- if the field name is nullpublic static Query newSlowRangeQuery(String field, long lowerValue, long upperValue)
lowerValue
and upperValue
included.
You can have half-open ranges (which are in fact </≤ or >/≥ queries)
by setting lowerValue = Long.MIN_VALUE
or upperValue = Long.MAX_VALUE
.
Ranges are inclusive. For exclusive ranges, pass Math.addExact(lowerValue, 1)
or Math.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 as
LongPoint.newRangeQuery(java.lang.String, long, long)
.
public static Query newSlowExactQuery(String field, 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 as
LongPoint.newExactQuery(java.lang.String, long)
.
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.