Package org.apache.lucene.spatial.prefix
Class RecursivePrefixTreeStrategy
java.lang.Object
org.apache.lucene.spatial.SpatialStrategy
org.apache.lucene.spatial.prefix.PrefixTreeStrategy
org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy
- Direct Known Subclasses:
NumberRangePrefixTreeStrategy
A
PrefixTreeStrategy
which uses AbstractVisitingPrefixTreeQuery
. This strategy
has support for searching non-point shapes (note: not tested). Even a query shape with
distErrPct=0 (fully precise to the grid) should have good performance for typical data, unless
there is a lot of indexed data coincident with the shape's edge.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.spatial.prefix.PrefixTreeStrategy
PrefixTreeStrategy.ShapeTokenStream
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected int
protected boolean
Fields inherited from class org.apache.lucene.spatial.prefix.PrefixTreeStrategy
defaultFieldValuesArrayLen, distErrPct, FIELD_TYPE, grid, pointsOnly
Fields inherited from class org.apache.lucene.spatial.SpatialStrategy
ctx
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateCellIteratorToIndex
(org.locationtech.spatial4j.shape.Shape shape, int detailLevel, Iterator<Cell> reuse) int
protected boolean
isGridAlignedShape
(org.locationtech.spatial4j.shape.Shape shape) A quick check of the shape to see if it is perfectly aligned to a grid.boolean
boolean
protected Query
makeGridShapeIntersectsQuery
(org.locationtech.spatial4j.shape.Shape gridShape) makeQuery(SpatialArgs)
specialized for the query being a grid square.makeQuery
(SpatialArgs args) void
setMultiOverlappingIndexedShapes
(boolean multiOverlappingIndexedShapes) void
setPrefixGridScanLevel
(int prefixGridScanLevel) Sets the grid level [1-maxLevels] at which indexed terms are scanned brute-force instead of by grid decomposition.void
setPruneLeafyBranches
(boolean pruneLeafyBranches) An optional hint affecting non-point shapes and tree cells implementingCellCanPrune
, otherwise ignored.toString()
Methods inherited from class org.apache.lucene.spatial.prefix.PrefixTreeStrategy
calcFacets, createIndexableFields, createIndexableFields, createIndexableFields, getDistErrPct, getGrid, isPointShape, isPointsOnly, makeDistanceValueSource, newCellToBytesRefIterator, setDefaultFieldValuesArrayLen, setDistErrPct, setPointsOnly, tokenStream
Methods inherited from class org.apache.lucene.spatial.SpatialStrategy
getFieldName, getSpatialContext, makeDistanceValueSource, makeRecipDistanceValueSource
-
Field Details
-
prefixGridScanLevel
protected int prefixGridScanLevel -
pruneLeafyBranches
protected boolean pruneLeafyBranches -
multiOverlappingIndexedShapes
protected boolean multiOverlappingIndexedShapes
-
-
Constructor Details
-
RecursivePrefixTreeStrategy
-
-
Method Details
-
getPrefixGridScanLevel
public int getPrefixGridScanLevel() -
setPrefixGridScanLevel
public void setPrefixGridScanLevel(int prefixGridScanLevel) Sets the grid level [1-maxLevels] at which indexed terms are scanned brute-force instead of by grid decomposition. By default this is maxLevels - 4. The final level, maxLevels, is always scanned.- Parameters:
prefixGridScanLevel
- 1 to maxLevels
-
isMultiOverlappingIndexedShapes
public boolean isMultiOverlappingIndexedShapes() -
setMultiOverlappingIndexedShapes
public void setMultiOverlappingIndexedShapes(boolean multiOverlappingIndexedShapes) -
isPruneLeafyBranches
public boolean isPruneLeafyBranches() -
setPruneLeafyBranches
public void setPruneLeafyBranches(boolean pruneLeafyBranches) An optional hint affecting non-point shapes and tree cells implementingCellCanPrune
, otherwise ignored.It will prune away a complete set sibling leaves to their parent (recursively), resulting in ~20-50% fewer indexed cells, and consequently that much less disk and that much faster indexing. So if it's a quad tree and all 4 sub-cells are there marked as a leaf, then they will be removed (pruned) and the parent is marked as a leaf instead. This occurs recursively on up. Unfortunately, the current implementation will buffer all cells to do this, so consider disabling for high precision (low distErrPct) shapes. (default=true)
-
toString
- Overrides:
toString
in classSpatialStrategy
-
createCellIteratorToIndex
protected Iterator<Cell> createCellIteratorToIndex(org.locationtech.spatial4j.shape.Shape shape, int detailLevel, Iterator<Cell> reuse) - Overrides:
createCellIteratorToIndex
in classPrefixTreeStrategy
-
makeQuery
Description copied from class:SpatialStrategy
Make a Query based principally onSpatialOperation
andShape
from the suppliedargs
. It should be constant scoring of 1.- Specified by:
makeQuery
in classSpatialStrategy
-
isGridAlignedShape
protected boolean isGridAlignedShape(org.locationtech.spatial4j.shape.Shape shape) A quick check of the shape to see if it is perfectly aligned to a grid. Points always are as they are indivisible. It's okay to return false if the shape actually is aligned; this is an optimization hint. -
makeGridShapeIntersectsQuery
makeQuery(SpatialArgs)
specialized for the query being a grid square.
-