Class CompositeSpatialStrategy
java.lang.Object
org.apache.lucene.spatial.SpatialStrategy
org.apache.lucene.spatial.composite.CompositeSpatialStrategy
A composite
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.- 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
ConstructorsConstructorDescriptionCompositeSpatialStrategy(String fieldName, RecursivePrefixTreeStrategy indexStrategy, SerializedDVStrategy geometryStrategy) -
Method Summary
Modifier and TypeMethodDescriptionField[]createIndexableFields(org.locationtech.spatial4j.shape.Shape shape) Returns the IndexableField(s) from theshapethat are to be added to theDocument.booleanmakeDistanceValueSource(org.locationtech.spatial4j.shape.Point queryPoint, double multiplier) Make a ValueSource returning the distance between the center of the indexed shape andqueryPoint.makeQuery(SpatialArgs args) voidsetOptimizePredicates(boolean optimizePredicates) Set to false to NOT use optimized search predicates that avoid checking the geometry sometimes.Methods inherited from class org.apache.lucene.spatial.SpatialStrategy
getFieldName, getSpatialContext, makeDistanceValueSource, makeRecipDistanceValueSource, toString
-
Constructor Details
-
CompositeSpatialStrategy
public CompositeSpatialStrategy(String fieldName, RecursivePrefixTreeStrategy indexStrategy, SerializedDVStrategy geometryStrategy)
-
-
Method Details
-
getIndexStrategy
-
getGeometryStrategy
-
isOptimizePredicates
public boolean isOptimizePredicates() -
setOptimizePredicates
public void setOptimizePredicates(boolean optimizePredicates) Set to false to NOT use optimized search predicates that avoid checking the geometry sometimes. Only useful for benchmarking. -
createIndexableFields
Description copied from class:SpatialStrategyReturns the IndexableField(s) from theshapethat 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:
createIndexableFieldsin 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:SpatialStrategyMake 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:
makeDistanceValueSourcein classSpatialStrategy
-
makeQuery
Description copied from class:SpatialStrategyMake a Query based principally onSpatialOperationandShapefrom the suppliedargs. It should be constant scoring of 1.- Specified by:
makeQueryin classSpatialStrategy
-