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

      public class RecursivePrefixTreeStrategy
      extends PrefixTreeStrategy

  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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `multiOverlappingIndexedShapes`
    `protected int` | `prefixGridScanLevel`
    `protected boolean` | `pruneLeafyBranches`

    - ### 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

    Constructors
    Constructor and Description
    `RecursivePrefixTreeStrategy(SpatialPrefixTree grid, String fieldName)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Iterator<Cell>` | `createCellIteratorToIndex(org.locationtech.spatial4j.shape.Shape shape, int detailLevel, Iterator<Cell> reuse)`
    `int` | `getPrefixGridScanLevel()`
    `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` | `isMultiOverlappingIndexedShapes()`
    `boolean` | `isPruneLeafyBranches()`
    `protected Query` | `makeGridShapeIntersectsQuery(org.locationtech.spatial4j.shape.Shape gridShape)` `makeQuery(SpatialArgs)` specialized for the query being a grid square.
    `Query` | `makeQuery(SpatialArgs args)` Make a Query based principally on `SpatialOperation` and `Shape` from the supplied `args`.
    `void` | `setMultiOverlappingIndexedShapes(boolean multiOverlappingIndexedShapes)` See `ContainsPrefixTreeQuery.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 implementing `CellCanPrune`, otherwise ignored.
    `String` | `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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### prefixGridScanLevel

          protected int prefixGridScanLevel

    - #### pruneLeafyBranches

          protected boolean pruneLeafyBranches

    - #### multiOverlappingIndexedShapes

          protected boolean multiOverlappingIndexedShapes

  - ### Constructor Detail

    - #### RecursivePrefixTreeStrategy

          public RecursivePrefixTreeStrategy(SpatialPrefixTree grid,
                                             String fieldName)

  - ### Method Detail

    - #### 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)

      See `ContainsPrefixTreeQuery.multiOverlappingIndexedShapes`.

    - #### isPruneLeafyBranches

          public boolean isPruneLeafyBranches()

    - #### setPruneLeafyBranches

          public void setPruneLeafyBranches(boolean pruneLeafyBranches)

      An optional hint affecting non-point shapes and tree cells implementing `CellCanPrune`, 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

          public String toString()

      Overrides:
        `toString` in class `SpatialStrategy`

    - #### createCellIteratorToIndex

          protected Iterator<Cell> createCellIteratorToIndex(org.locationtech.spatial4j.shape.Shape shape,
                                                             int detailLevel,
                                                             Iterator<Cell> reuse)

      Overrides:
        `createCellIteratorToIndex` in class `PrefixTreeStrategy`

    - #### makeQuery

          public Query makeQuery(SpatialArgs args)

      Description copied from class: `SpatialStrategy`
      Make a Query based principally on `SpatialOperation` and `Shape` from the supplied `args`. It should be constant scoring of 1.
      Specified by:
        `makeQuery` in class `SpatialStrategy`

    - #### 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

          protected Query makeGridShapeIntersectsQuery(org.locationtech.spatial4j.shape.Shape gridShape)

      `makeQuery(SpatialArgs)` specialized for the query being a grid square.

Copyright © 2000-2024 Apache Software Foundation. All Rights Reserved.