org.apache.lucene.spatial.vector

## Class PointVectorStrategy

- java.lang.Object
- - org.apache.lucene.spatial.SpatialStrategy
  - - org.apache.lucene.spatial.vector.PointVectorStrategy

-     public class PointVectorStrategy
      extends SpatialStrategy

  Simple `SpatialStrategy` which represents Points in two numeric `DoubleField`s. 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.
  - Uses the FieldCache for `makeDistanceValueSource(com.spatial4j.core.shape.Point)` and for searching with a Circle.

  #### Implementation:

  This is a simple Strategy. Search works with `NumericRangeQuery`s on an x & y pair of fields. A Circle query does the same bbox query but adds a ValueSource filter on `makeDistanceValueSource(com.spatial4j.core.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.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `precisionStep`
    `static String` | `SUFFIX_X`
    `static String` | `SUFFIX_Y`

    - ### Fields inherited from class org.apache.lucene.spatial.SpatialStrategy

      `ctx`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PointVectorStrategy(com.spatial4j.core.context.SpatialContext ctx, String fieldNamePrefix)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Field[]` | `createIndexableFields(com.spatial4j.core.shape.Point point)`
    `Field[]` | `createIndexableFields(com.spatial4j.core.shape.Shape shape)` Returns the IndexableField(s) from the `shape` that are to be added to the `Document`.
    `ValueSource` | `makeDistanceValueSource(com.spatial4j.core.shape.Point queryPoint)` Make a ValueSource returning the distance between the center of the indexed shape and `queryPoint`.
    `Filter` | `makeFilter(SpatialArgs args)` Make a Filter based principally on `SpatialOperation` and `Shape` from the supplied `args`.
    `ConstantScoreQuery` | `makeQuery(SpatialArgs args)` Make a Query based principally on `SpatialOperation` and `Shape` from the supplied `args`.
    `Query` | `makeQueryDistanceScore(SpatialArgs args)`
    `void` | `setPrecisionStep(int p)`

    - ### Methods inherited from class org.apache.lucene.spatial.SpatialStrategy

      `getFieldName, getSpatialContext, makeRecipDistanceValueSource, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### SUFFIX_X

          public static final String SUFFIX_X

      See Also:
        Constant Field Values

    - #### SUFFIX_Y

          public static final String SUFFIX_Y

      See Also:
        Constant Field Values

    - #### precisionStep

          public int precisionStep

  - ### Constructor Detail

    - #### PointVectorStrategy

          public PointVectorStrategy(com.spatial4j.core.context.SpatialContext ctx,
                             String fieldNamePrefix)

  - ### Method Detail

    - #### setPrecisionStep

          public void setPrecisionStep(int p)

    - #### createIndexableFields

          public Field[] createIndexableFields(com.spatial4j.core.shape.Shape shape)

      Description copied from class: `SpatialStrategy`
      Returns the IndexableField(s) from the `shape` that are to be added to the `Document`. These fields are expected to be marked as indexed and not stored.

      Note: If you want to store the shape as a string for retrieval in search results, you could add it like this:

          document.add(new StoredField(fieldName,ctx.toString(shape)));

      The particular string representation used doesn't matter to the Strategy since it doesn't use it.
      Specified by:
        `createIndexableFields` in class `SpatialStrategy`
      Returns:
        Not null nor will it have null elements.

    - #### createIndexableFields

          public Field[] createIndexableFields(com.spatial4j.core.shape.Point point)

      See Also:
        `createIndexableFields(com.spatial4j.core.shape.Shape)`

    - #### makeDistanceValueSource

          public ValueSource makeDistanceValueSource(com.spatial4j.core.shape.Point queryPoint)

      Description copied from class: `SpatialStrategy`
      Make a ValueSource returning the distance between the center of the indexed shape and `queryPoint`. If there are multiple indexed shapes then the closest one is chosen.
      Specified by:
        `makeDistanceValueSource` in class `SpatialStrategy`

    - #### makeFilter

          public Filter makeFilter(SpatialArgs args)

      Description copied from class: `SpatialStrategy`
      Make a Filter based principally on `SpatialOperation` and `Shape` from the supplied `args`.

      If a subclasses implements `SpatialStrategy.makeQuery(org.apache.lucene.spatial.query.SpatialArgs)` then this method could be simply:

          return new QueryWrapperFilter(makeQuery(args).getQuery());

      Specified by:
        `makeFilter` in class `SpatialStrategy`

    - #### makeQuery

          public ConstantScoreQuery makeQuery(SpatialArgs args)

      Description copied from class: `SpatialStrategy`
      Make a Query based principally on `SpatialOperation` and `Shape` from the supplied `args`. The default implementation is

          return new ConstantScoreQuery(makeFilter(args));

      Overrides:
        `makeQuery` in class `SpatialStrategy`

    - #### makeQueryDistanceScore

          public Query makeQueryDistanceScore(SpatialArgs args)

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.