java.lang.Object
org.apache.lucene.document.Field
org.apache.lucene.document.IntField
- All Implemented Interfaces:
IndexableField
Field that stores a per-document
int
value for scoring, sorting or value retrieval
and index the field for fast range filters. If you also need to store the value, you should add a
separate StoredField
instance. If you need more fine-grained control you can use IntPoint
and NumericDocValuesField
or SortedNumericDocValuesField
.
This field defines static factory methods for creating common queries:
newExactQuery(String, int)
for matching an exact 1D point.newRangeQuery(String, int, int)
for matching a 1D range.newSetQuery(String, int...)
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
FieldsFields inherited from class org.apache.lucene.document.Field
fieldsData, name, tokenStream, type
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionNon-null if this field has a binary valuestatic Query
newExactQuery
(String field, int value) Create a query for matching an exact integer value.static Query
newRangeQuery
(String field, int lowerValue, int upperValue) Create a range query for integer values.static Query
newSetQuery
(String field, int... values) Create a query matching values in a supplied setstatic SortField
newSortField
(String field, boolean reverse, SortedNumericSelector.Type selector) Create a newSortField
for int values.toString()
Prints a Field for human consumption.Methods inherited from class org.apache.lucene.document.Field
fieldType, getCharSequenceValue, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue
-
Field Details
-
FIELD_TYPE
-
-
Constructor Details
-
IntField
Creates a new IntField, indexing the provided point and storing it as a DocValue- Parameters:
name
- field namevalue
- the int value- Throws:
IllegalArgumentException
- if the field name or value is null.
-
-
Method Details
-
binaryValue
Description copied from interface:IndexableField
Non-null if this field has a binary value- Specified by:
binaryValue
in interfaceIndexableField
- Overrides:
binaryValue
in classField
-
toString
Description copied from class:Field
Prints a Field for human consumption. -
newExactQuery
Create a query for matching an exact integer value.- Parameters:
field
- field name. must not benull
.value
- exact value- Returns:
- a query matching documents with this exact value
- Throws:
IllegalArgumentException
- iffield
is null.
-
newRangeQuery
Create a range query for integer values.You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting
lowerValue = Integer.MIN_VALUE
orupperValue = Integer.MAX_VALUE
.Ranges are inclusive. For exclusive ranges, pass
Math.addExact(lowerValue, 1)
orMath.addExact(upperValue, -1)
.- 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
- iffield
is null.
-
newSetQuery
Create a query matching values in a supplied set- Parameters:
field
- field name. must not benull
.values
- integer values- Returns:
- a query matching documents within this set.
- Throws:
IllegalArgumentException
- iffield
is null.
-
newSortField
public static SortField newSortField(String field, boolean reverse, SortedNumericSelector.Type selector) Create a newSortField
for int 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.
-