Package org.apache.lucene.document
Class XYPointField
java.lang.Object
org.apache.lucene.document.Field
org.apache.lucene.document.XYPointField
- All Implemented Interfaces:
IndexableField
An indexed XY position field.
Finding all documents within a range at search time is efficient. Multiple values for the same field in one document is allowed.
This field defines static factory methods for common operations:
newBoxQuery()
for matching points within a bounding box.newDistanceQuery()
for matching points within a specified distance.newPolygonQuery()
for matching points within an arbitrary polygon.newGeometryQuery()
for matching points within an arbitrary geometry collection.
If you also need per-document operations such as sort by distance, add a separate XYDocValuesField
instance. If you also need to store the value, you should add a separate StoredField
instance.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.document.Field
Field.Store
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
XYPoint is encoded as integer values so number of bytes is 4static final FieldType
Type for an indexed XYPointFields inherited from class org.apache.lucene.document.Field
fieldsData, name, tokenStream, type
-
Constructor Summary
ConstructorDescriptionXYPointField
(String name, float x, float y) Creates a new XYPoint with the specified x and y -
Method Summary
Modifier and TypeMethodDescriptionstatic Query
newBoxQuery
(String field, float minX, float maxX, float minY, float maxY) Create a query for matching a bounding box.static Query
newDistanceQuery
(String field, float x, float y, float radius) Create a query for matching points within the specified distance of the supplied location.static Query
newGeometryQuery
(String field, XYGeometry... xyGeometries) create a query to find all indexed shapes that intersect a provided geometry collection.static Query
newPolygonQuery
(String field, XYPolygon... polygons) Create a query for matching one or more polygons.void
setLocationValue
(float x, float y) Change the values of this fieldtoString()
Prints a Field for human consumption.Methods inherited from class org.apache.lucene.document.Field
binaryValue, fieldType, getCharSequenceValue, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue
-
Field Details
-
BYTES
public static final int BYTESXYPoint is encoded as integer values so number of bytes is 4- See Also:
-
TYPE
Type for an indexed XYPointEach point stores two dimensions with 4 bytes per dimension.
-
-
Constructor Details
-
XYPointField
Creates a new XYPoint with the specified x and y- Parameters:
name
- field namex
- x value.y
- y value.
-
-
Method Details
-
setLocationValue
public void setLocationValue(float x, float y) Change the values of this field- Parameters:
x
- x value.y
- y value.
-
toString
Description copied from class:Field
Prints a Field for human consumption. -
newBoxQuery
Create a query for matching a bounding box.- Parameters:
field
- field name. must not be null.minX
- x lower bound.maxX
- x upper bound.minY
- y lower bound.maxY
- y upper bound.- Returns:
- query matching points within this box
- Throws:
IllegalArgumentException
- iffield
is null, or the box has invalid coordinates.
-
newDistanceQuery
Create a query for matching points within the specified distance of the supplied location.- Parameters:
field
- field name. must not be null.x
- x at the center.y
- y at the center.radius
- maximum distance from the center in cartesian units: must be non-negative and finite.- Returns:
- query matching points within this distance
- Throws:
IllegalArgumentException
- iffield
is null, location has invalid coordinates, or radius is invalid.
-
newPolygonQuery
Create a query for matching one or more polygons.- Parameters:
field
- field name. must not be null.polygons
- array of polygons. must not be null or empty- Returns:
- query matching points within this polygon
- Throws:
IllegalArgumentException
- iffield
is null,polygons
is null or empty- See Also:
-
newGeometryQuery
create a query to find all indexed shapes that intersect a provided geometry collection. XYLine geometries are not supported.- Parameters:
field
- field name. must not be null.xyGeometries
- array of geometries. must not be null or empty.- Returns:
- query matching points within this geometry collection.
- Throws:
IllegalArgumentException
- iffield
is null,polygons
is null, empty or contains a null or XYLine geometry.- See Also:
-