public class SerializedDVStrategy extends SpatialStrategy
RecursivePrefixTreeStrategy
)
to add precision or eventually make more specific / advanced calculations on the per-document
geometry.
The serialization uses Spatial4j's BinaryCodec
.ctx
Constructor and Description |
---|
SerializedDVStrategy(com.spatial4j.core.context.SpatialContext ctx,
String fieldName)
Constructs the spatial strategy with its mandatory arguments.
|
Modifier and Type | Method and Description |
---|---|
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,
double multiplier)
Make a ValueSource returning the distance between the center of the
indexed shape and
queryPoint . |
Filter |
makeFilter(SpatialArgs args)
Returns a Filter that should be used with
FilteredQuery.QUERY_FIRST_FILTER_STRATEGY . |
Query |
makeQuery(SpatialArgs args)
|
ValueSource |
makeShapeValueSource()
Provides access to each shape per document as a ValueSource in which
FunctionValues.objectVal(int) returns a Shape . |
getFieldName, getSpatialContext, makeDistanceValueSource, makeRecipDistanceValueSource, toString
public SerializedDVStrategy(com.spatial4j.core.context.SpatialContext ctx, String fieldName)
public Field[] createIndexableFields(com.spatial4j.core.shape.Shape shape)
SpatialStrategy
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.
createIndexableFields
in class SpatialStrategy
public ValueSource makeDistanceValueSource(com.spatial4j.core.shape.Point queryPoint, double multiplier)
SpatialStrategy
queryPoint
. If there are multiple indexed shapes
then the closest one is chosen. The result is multiplied by multiplier
, which
conveniently is used to get the desired units.makeDistanceValueSource
in class SpatialStrategy
public Query makeQuery(SpatialArgs args)
SpatialStrategy
SpatialOperation
and Shape
from the supplied args
.
The default implementation is
return new ConstantScoreQuery(makeFilter(args));
makeQuery
in class SpatialStrategy
public Filter makeFilter(SpatialArgs args)
FilteredQuery.QUERY_FIRST_FILTER_STRATEGY
.
Use in another manner is likely to result in an UnsupportedOperationException
to prevent misuse because the filter can't efficiently work via iteration.makeFilter
in class SpatialStrategy
public ValueSource makeShapeValueSource()
FunctionValues.objectVal(int)
returns a Shape
.Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.