public final class IntPoint extends Field
int
field for fast range filters. If you also
need to store the value, you should add a separate StoredField
instance.
Finding all documents within an N-dimensional shape or range at search time is efficient. Multiple values for the same field in one document is allowed.
This field defines static factory methods for creating common queries:
newExactQuery(String, int)
for matching an exact 1D point.
newSetQuery(String, int...)
for matching a set of 1D values.
newRangeQuery(String, int, int)
for matching a 1D range.
newRangeQuery(String, int[], int[])
for matching points/ranges in n-dimensional space.
PointValues
Field.Store
boost, fieldsData, name, tokenStream, type
Constructor and Description |
---|
IntPoint(String name,
int... point)
Creates a new IntPoint, indexing the
provided N-dimensional int point.
|
Modifier and Type | Method and Description |
---|---|
static int |
decodeDimension(byte[] value,
int offset)
Decode single integer dimension
|
static void |
encodeDimension(int value,
byte[] dest,
int offset)
Encode single integer dimension
|
static 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 n-dimensional integer values.
|
static Query |
newRangeQuery(String field,
int lowerValue,
int upperValue)
Create a range query for integer values.
|
static Query |
newSetQuery(String field,
Collection<Integer> values)
Create a query matching any of the specified 1D values.
|
static Query |
newSetQuery(String field,
int... values)
Create a query matching any of the specified 1D values.
|
Number |
numericValue()
Non-null if this field has a numeric value
|
void |
setBytesValue(BytesRef bytes)
Expert: change the value of this field.
|
void |
setIntValue(int value)
Expert: change the value of this field.
|
void |
setIntValues(int... point)
Change the values of this field
|
String |
toString()
Prints a Field for human consumption.
|
binaryValue, boost, fieldType, name, readerValue, setBoost, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue
public IntPoint(String name, int... point)
name
- field namepoint
- int[] valueIllegalArgumentException
- if the field name or value is null.public void setIntValue(int value)
Field
Field.setStringValue(String)
.setIntValue
in class Field
public void setIntValues(int... point)
public void setBytesValue(BytesRef bytes)
Field
Field.setStringValue(String)
.
NOTE: the provided BytesRef is not copied so be sure not to change it until you're done with this field.
setBytesValue
in class Field
public Number numericValue()
IndexableField
numericValue
in interface IndexableField
numericValue
in class Field
public String toString()
Field
public static void encodeDimension(int value, byte[] dest, int offset)
public static int decodeDimension(byte[] value, int offset)
public static Query newExactQuery(String field, int value)
This is for simple one-dimension points, for multidimensional points use
newRangeQuery(String, int[], int[])
instead.
field
- field name. must not be null
.value
- exact valueIllegalArgumentException
- if field
is null.public static Query newRangeQuery(String field, int lowerValue, int upperValue)
This is for simple one-dimension ranges, for multidimensional ranges use
newRangeQuery(String, int[], int[])
instead.
You can have half-open ranges (which are in fact </≤ or >/≥ queries)
by setting lowerValue = Integer.MIN_VALUE
or upperValue = Integer.MAX_VALUE
.
Ranges are inclusive. For exclusive ranges, pass Math.addExact(lowerValue, 1)
or Math.addExact(upperValue, -1)
.
field
- field name. must not be null
.lowerValue
- lower portion of the range (inclusive).upperValue
- upper portion of the range (inclusive).IllegalArgumentException
- if field
is null.public static Query newRangeQuery(String field, int[] lowerValue, int[] upperValue)
You can have half-open ranges (which are in fact </≤ or >/≥ queries)
by setting lowerValue[i] = Integer.MIN_VALUE
or upperValue[i] = Integer.MAX_VALUE
.
Ranges are inclusive. For exclusive ranges, pass Math.addExact(lowerValue[i], 1)
or Math.addExact(upperValue[i], -1)
.
field
- field name. must not be null
.lowerValue
- lower portion of the range (inclusive). must not be null
.upperValue
- upper portion of the range (inclusive). must not be null
.IllegalArgumentException
- if field
is null, if lowerValue
is null, if upperValue
is null,
or if lowerValue.length != upperValue.length
public static Query newSetQuery(String field, int... values)
TermsQuery
.field
- field name. must not be null
.values
- all values to matchpublic static Query newSetQuery(String field, Collection<Integer> values)
TermsQuery
.field
- field name. must not be null
.values
- all values to matchCopyright © 2000-2016 Apache Software Foundation. All Rights Reserved.