Class IntPoint
- java.lang.Object
-
- org.apache.lucene.document.Field
-
- org.apache.lucene.document.IntPoint
-
- All Implemented Interfaces:
IndexableField
public final class IntPoint extends Field
An indexedint
field for fast range filters. If you also need to store the value, you should add a separateStoredField
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.
- 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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
decodeDimension(byte[] value, int offset)
Decode single integer dimensionstatic void
encodeDimension(int value, byte[] dest, int offset)
Encode single integer dimensionstatic 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, int... values)
Create a query matching any of the specified 1D values.static Query
newSetQuery(String field, Collection<Integer> values)
Create a query matching any of the specified 1D values.Number
numericValue()
Non-null if this field has a numeric valuestatic BytesRef
pack(int... point)
Pack an integer point into a BytesRefvoid
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 fieldString
toString()
Prints a Field for human consumption.-
Methods inherited from class org.apache.lucene.document.Field
binaryValue, fieldType, getCharSequenceValue, invertableType, name, readerValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, storedValue, stringValue, tokenStream, tokenStreamValue
-
-
-
-
Constructor Detail
-
IntPoint
public IntPoint(String name, int... point)
Creates a new IntPoint, indexing the provided N-dimensional int point.- Parameters:
name
- field namepoint
- int[] value- Throws:
IllegalArgumentException
- if the field name or value is null.
-
-
Method Detail
-
setIntValue
public void setIntValue(int value)
Description copied from class:Field
Expert: change the value of this field. SeeField.setStringValue(String)
.- Overrides:
setIntValue
in classField
-
setIntValues
public void setIntValues(int... point)
Change the values of this field
-
setBytesValue
public void setBytesValue(BytesRef bytes)
Description copied from class:Field
Expert: change the value of this field. SeeField.setStringValue(String)
.NOTE: the provided BytesRef is not copied so be sure not to change it until you're done with this field.
- Overrides:
setBytesValue
in classField
-
numericValue
public Number numericValue()
Description copied from interface:IndexableField
Non-null if this field has a numeric value- Specified by:
numericValue
in interfaceIndexableField
- Overrides:
numericValue
in classField
-
pack
public static BytesRef pack(int... point)
Pack an integer point into a BytesRef- Parameters:
point
- int[] value- Throws:
IllegalArgumentException
- is the value is null or of zero length
-
toString
public String toString()
Description copied from class:Field
Prints a Field for human consumption.
-
encodeDimension
public static void encodeDimension(int value, byte[] dest, int offset)
Encode single integer dimension
-
decodeDimension
public static int decodeDimension(byte[] value, int offset)
Decode single integer dimension
-
newExactQuery
public static Query newExactQuery(String field, int value)
Create a query for matching an exact integer value.This is for simple one-dimension points, for multidimensional points use
newRangeQuery(String, int[], int[])
instead.- 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
public static Query newRangeQuery(String field, int lowerValue, int upperValue)
Create a range query for integer values.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
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.
-
newRangeQuery
public static Query newRangeQuery(String field, int[] lowerValue, int[] upperValue)
Create a range query for n-dimensional integer values.You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting
lowerValue[i] = Integer.MIN_VALUE
orupperValue[i] = Integer.MAX_VALUE
.Ranges are inclusive. For exclusive ranges, pass
Math.addExact(lowerValue[i], 1)
orMath.addExact(upperValue[i], -1)
.- Parameters:
field
- field name. must not benull
.lowerValue
- lower portion of the range (inclusive). must not benull
.upperValue
- upper portion of the range (inclusive). must not benull
.- Returns:
- a query matching documents within this range.
- Throws:
IllegalArgumentException
- iffield
is null, iflowerValue
is null, ifupperValue
is null, or iflowerValue.length != upperValue.length
-
newSetQuery
public static Query newSetQuery(String field, int... values)
Create a query matching any of the specified 1D values. This is the points equivalent ofTermsQuery
.- Parameters:
field
- field name. must not benull
.values
- all values to match
-
newSetQuery
public static Query newSetQuery(String field, Collection<Integer> values)
Create a query matching any of the specified 1D values. This is the points equivalent ofTermsQuery
.- Parameters:
field
- field name. must not benull
.values
- all values to match
-
-