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
FieldsModifier and TypeFieldDescriptionstatic final intXYPoint is encoded as integer values so number of bytes is 4static final FieldTypeType for an indexed XYPointFields inherited from class org.apache.lucene.document.Field
fieldsData, name, type -
Constructor Summary
ConstructorsConstructorDescriptionXYPointField(String name, float x, float y) Creates a new XYPoint with the specified x and y -
Method Summary
Modifier and TypeMethodDescriptionstatic QuerynewBoxQuery(String field, float minX, float maxX, float minY, float maxY) Create a query for matching a bounding box.static QuerynewDistanceQuery(String field, float x, float y, float radius) Create a query for matching points within the specified distance of the supplied location.static QuerynewGeometryQuery(String field, XYGeometry... xyGeometries) create a query to find all indexed shapes that intersect a provided geometry collection.static QuerynewPolygonQuery(String field, XYPolygon... polygons) Create a query for matching one or more polygons.voidsetLocationValue(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, invertableType, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, storedValue, 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:FieldPrints 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- iffieldis 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- iffieldis 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- iffieldis null,polygonsis 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- iffieldis null,polygonsis null, empty or contains a null or XYLine geometry.- See Also:
-