public class CompositeSpatialStrategy extends SpatialStrategy
SpatialStrategy
based on RecursivePrefixTreeStrategy
(RPT) and
SerializedDVStrategy
(SDV).
RPT acts as an index to the precision available in SDV, and in some circumstances can avoid geometry lookups based
on where a cell is in relation to the query shape. Currently the only predicate optimized like this is Intersects.
All predicates are supported except for the BBox* ones, and Disjoint.ctx
Constructor and Description |
---|
CompositeSpatialStrategy(String fieldName,
RecursivePrefixTreeStrategy indexStrategy,
SerializedDVStrategy geometryStrategy) |
Modifier and Type | Method and Description |
---|---|
Field[] |
createIndexableFields(org.locationtech.spatial4j.shape.Shape shape)
Returns the IndexableField(s) from the
shape that are to be
added to the Document . |
SerializedDVStrategy |
getGeometryStrategy() |
RecursivePrefixTreeStrategy |
getIndexStrategy() |
boolean |
isOptimizePredicates() |
DoubleValuesSource |
makeDistanceValueSource(org.locationtech.spatial4j.shape.Point queryPoint,
double multiplier)
Make a ValueSource returning the distance between the center of the
indexed shape and
queryPoint . |
Query |
makeQuery(SpatialArgs args)
|
void |
setOptimizePredicates(boolean optimizePredicates)
Set to false to NOT use optimized search predicates that avoid checking the geometry sometimes.
|
getFieldName, getSpatialContext, makeDistanceValueSource, makeRecipDistanceValueSource, toString
public CompositeSpatialStrategy(String fieldName, RecursivePrefixTreeStrategy indexStrategy, SerializedDVStrategy geometryStrategy)
public RecursivePrefixTreeStrategy getIndexStrategy()
public SerializedDVStrategy getGeometryStrategy()
public boolean isOptimizePredicates()
public void setOptimizePredicates(boolean optimizePredicates)
public Field[] createIndexableFields(org.locationtech.spatial4j.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 DoubleValuesSource makeDistanceValueSource(org.locationtech.spatial4j.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
. It should be constant scoring of 1.makeQuery
in class SpatialStrategy
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.