Class XYPointField

  • All Implemented Interfaces:
    IndexableField

    public class XYPointField
    extends Field
    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:

    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:
    PointValues, XYDocValuesField
    • Field Detail

      • BYTES

        public static final int BYTES
        XYPoint is encoded as integer values so number of bytes is 4
        See Also:
        Constant Field Values
      • TYPE

        public static final FieldType TYPE
        Type for an indexed XYPoint

        Each point stores two dimensions with 4 bytes per dimension.

    • Constructor Detail

      • XYPointField

        public XYPointField​(String name,
                            float x,
                            float y)
        Creates a new XYPoint with the specified x and y
        Parameters:
        name - field name
        x - x value.
        y - y value.
    • Method Detail

      • setLocationValue

        public void setLocationValue​(float x,
                                     float y)
        Change the values of this field
        Parameters:
        x - x value.
        y - y value.
      • toString

        public String toString()
        Description copied from class: Field
        Prints a Field for human consumption.
        Overrides:
        toString in class Field
      • newBoxQuery

        public static Query newBoxQuery​(String field,
                                        float minX,
                                        float maxX,
                                        float minY,
                                        float maxY)
        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 - if field is null, or the box has invalid coordinates.
      • newDistanceQuery

        public 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.
        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 - if field is null, location has invalid coordinates, or radius is invalid.
      • newPolygonQuery

        public static Query newPolygonQuery​(String field,
                                            XYPolygon... polygons)
        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 - if field is null, polygons is null or empty
        See Also:
        Polygon
      • newGeometryQuery

        public static Query newGeometryQuery​(String field,
                                             XYGeometry... xyGeometries)
        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 - if field is null, polygons is null, empty or contains a null or XYLine geometry.
        See Also:
        XYGeometry