Class PointVectorStrategy


  • public class PointVectorStrategy
    extends org.apache.lucene.spatial.SpatialStrategy
    Simple SpatialStrategy which represents Points in two numeric fields. The Strategy's best feature is decent distance sort.

    Characteristics:

    • Only indexes points; just one per field value.
    • Can query by a rectangle or circle.
    • SpatialOperation.Intersects and SpatialOperation.IsWithin is supported.
    • Requires DocValues for SpatialStrategy.makeDistanceValueSource(org.locationtech.spatial4j.shape.Point) and for searching with a Circle.

    Implementation:

    This is a simple Strategy. Search works with a pair of range queries on two DoublePoints representing x & y fields. A Circle query does the same bbox query but adds a ValueSource filter on SpatialStrategy.makeDistanceValueSource(org.locationtech.spatial4j.shape.Point).

    One performance shortcoming with this strategy is that a scenario involving both a search using a Circle and sort will result in calculations for the spatial distance being done twice -- once for the filter and second for the sort.

    WARNING: This API is experimental and might change in incompatible ways in the next release.
    • Constructor Detail

      • PointVectorStrategy

        public PointVectorStrategy​(org.locationtech.spatial4j.context.SpatialContext ctx,
                                   String fieldNamePrefix,
                                   org.apache.lucene.document.FieldType fieldType)
        Create a new instance configured with the provided FieldType options. See DEFAULT_FIELDTYPE. a field type is used to articulate the desired options (namely pointValues, docValues, stored). Legacy numerics is configurable this way too.
    • Method Detail

      • newInstance

        public static PointVectorStrategy newInstance​(org.locationtech.spatial4j.context.SpatialContext ctx,
                                                      String fieldNamePrefix)
        Create a new PointVectorStrategy instance that uses DoublePoint and DoublePoint.newRangeQuery(java.lang.String, double, double)
      • createIndexableFields

        public org.apache.lucene.document.Field[] createIndexableFields​(org.locationtech.spatial4j.shape.Shape shape)
        Specified by:
        createIndexableFields in class org.apache.lucene.spatial.SpatialStrategy
      • makeDistanceValueSource

        public org.apache.lucene.search.DoubleValuesSource makeDistanceValueSource​(org.locationtech.spatial4j.shape.Point queryPoint,
                                                                                   double multiplier)
        Specified by:
        makeDistanceValueSource in class org.apache.lucene.spatial.SpatialStrategy
      • makeQuery

        public org.apache.lucene.search.ConstantScoreQuery makeQuery​(org.apache.lucene.spatial.query.SpatialArgs args)
        Specified by:
        makeQuery in class org.apache.lucene.spatial.SpatialStrategy