Class SerializedDVStrategy
- java.lang.Object
-
- org.apache.lucene.spatial.SpatialStrategy
-
- org.apache.lucene.spatial.serialized.SerializedDVStrategy
-
public class SerializedDVStrategy extends SpatialStrategy
A SpatialStrategy based on serializing a Shape stored into BinaryDocValues. This is not at all fast; it's designed to be used in conjunction with another index based SpatialStrategy that is approximated (likeRecursivePrefixTreeStrategy
) to add precision or eventually make more specific / advanced calculations on the per-document geometry. The serialization uses Spatial4j'sBinaryCodec
.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.spatial.SpatialStrategy
ctx
-
-
Constructor Summary
Constructors Constructor Description SerializedDVStrategy(org.locationtech.spatial4j.context.SpatialContext ctx, String fieldName)
Constructs the spatial strategy with its mandatory arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Field[]
createIndexableFields(org.locationtech.spatial4j.shape.Shape shape)
Returns the IndexableField(s) from theshape
that are to be added to theDocument
.DoubleValuesSource
makeDistanceValueSource(org.locationtech.spatial4j.shape.Point queryPoint, double multiplier)
Make a ValueSource returning the distance between the center of the indexed shape andqueryPoint
.Query
makeQuery(SpatialArgs args)
Returns a Query that should be used in a random-access fashion.ShapeValuesSource
makeShapeValueSource()
Provides access to each shape per document-
Methods inherited from class org.apache.lucene.spatial.SpatialStrategy
getFieldName, getSpatialContext, makeDistanceValueSource, makeRecipDistanceValueSource, toString
-
-
-
-
Constructor Detail
-
SerializedDVStrategy
public SerializedDVStrategy(org.locationtech.spatial4j.context.SpatialContext ctx, String fieldName)
Constructs the spatial strategy with its mandatory arguments.
-
-
Method Detail
-
createIndexableFields
public Field[] createIndexableFields(org.locationtech.spatial4j.shape.Shape shape)
Description copied from class:SpatialStrategy
Returns the IndexableField(s) from theshape
that are to be added to theDocument
. 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 classSpatialStrategy
- Returns:
- Not null nor will it have null elements.
-
makeDistanceValueSource
public DoubleValuesSource makeDistanceValueSource(org.locationtech.spatial4j.shape.Point queryPoint, double multiplier)
Description copied from class:SpatialStrategy
Make a ValueSource returning the distance between the center of the indexed shape andqueryPoint
. If there are multiple indexed shapes then the closest one is chosen. The result is multiplied bymultiplier
, which conveniently is used to get the desired units.- Specified by:
makeDistanceValueSource
in classSpatialStrategy
-
makeQuery
public Query makeQuery(SpatialArgs args)
Returns a Query that should be used in a random-access fashion. Use in another manner will be SLOW.- Specified by:
makeQuery
in classSpatialStrategy
-
makeShapeValueSource
public ShapeValuesSource makeShapeValueSource()
Provides access to each shape per document
-
-