NumberRangePrefixTreeStrategy (Lucene 10.5.1 spatial-extras API)
Description: declaration: package: org.apache.lucene.spatial.prefix, class: NumberRangePrefixTreeStrategy

Package org.apache.lucene.spatial.prefix

# Class NumberRangePrefixTreeStrategy

java.lang.Object
org.apache.lucene.spatial.SpatialStrategy
org.apache.lucene.spatial.prefix.PrefixTreeStrategy
org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy
org.apache.lucene.spatial.prefix.NumberRangePrefixTreeStrategy

public class NumberRangePrefixTreeStrategy extends RecursivePrefixTreeStrategy
A PrefixTree based on Number/Date ranges. This isn't very "spatial" on the surface (to the user) but it's implemented using spatial so that's why it's here extending a SpatialStrategy. When using this class, you will use various utility methods on the prefix tree implementation to convert objects/strings to/from shapes.

To use with dates, pass in `DateRangePrefixTree`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `NumberRangePrefixTreeStrategy.Facets`
  Facet response information

  ## Nested classes/interfaces inherited from class org.apache.lucene.spatial.prefix.PrefixTreeStrategy

  `PrefixTreeStrategy.ShapeTokenStream`

- ## Field Summary

  ### Fields inherited from class org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy

  `multiOverlappingIndexedShapes, prefixGridScanLevel, 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
  Description
  `NumberRangePrefixTreeStrategy(NumberRangePrefixTree prefixTree, String fieldName)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `NumberRangePrefixTreeStrategy.Facets`
  `calcFacets(IndexReaderContext context, Bits topAcceptDocs, NumberRangePrefixTree.UnitNRShape start, NumberRangePrefixTree.UnitNRShape end)`
  Calculates facets between `start` and `end` to a detail level one greater than that provided by the arguments.
  `NumberRangePrefixTreeStrategy.Facets`
  `calcFacets(IndexReaderContext context, Bits topAcceptDocs, org.locationtech.spatial4j.shape.Shape facetRange, int level)`
  Calculates facets (aggregated counts) given a range shape (start-end span) and a level, which specifies the detail.
  `NumberRangePrefixTree`
  `getGrid()`
  `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.
  `protected boolean`
  `isPointShape(org.locationtech.spatial4j.shape.Shape shape)`
  Returns true if the `shape` is a `Point`.
  `DoubleValuesSource`
  `makeDistanceValueSource(org.locationtech.spatial4j.shape.Point queryPoint, double multiplier)`
  Unsupported.

  ### Methods inherited from class org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy

  `createCellIteratorToIndex, getPrefixGridScanLevel, isMultiOverlappingIndexedShapes, isPruneLeafyBranches, makeGridShapeIntersectsQuery, makeQuery, setMultiOverlappingIndexedShapes, setPrefixGridScanLevel, setPruneLeafyBranches, toString`

  ### Methods inherited from class org.apache.lucene.spatial.prefix.PrefixTreeStrategy

  `calcFacets, createIndexableFields, createIndexableFields, createIndexableFields, getDistErrPct, isPointsOnly, 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`

- ## Constructor Details

  - ### NumberRangePrefixTreeStrategy

    public NumberRangePrefixTreeStrategy(NumberRangePrefixTree prefixTree, String fieldName)

- ## Method Details

  - ### getGrid

    public NumberRangePrefixTree getGrid()
    Overrides:
      `getGrid` in class `PrefixTreeStrategy`

  - ### isPointShape

    protected boolean isPointShape(org.locationtech.spatial4j.shape.Shape shape)
    Description copied from class: `PrefixTreeStrategy`
    Returns true if the `shape` is a `Point`. For custom spatial contexts, it may make sense to have certain other shapes return true.
    Overrides:
      `isPointShape` in class `PrefixTreeStrategy`

  - ### isGridAlignedShape

    protected boolean isGridAlignedShape(org.locationtech.spatial4j.shape.Shape shape)
    Description copied from class: `RecursivePrefixTreeStrategy`
    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.
    Overrides:
      `isGridAlignedShape` in class `RecursivePrefixTreeStrategy`

  - ### makeDistanceValueSource

    public DoubleValuesSource makeDistanceValueSource(org.locationtech.spatial4j.shape.Point queryPoint, double multiplier)
    Unsupported.
    Overrides:
      `makeDistanceValueSource` in class `PrefixTreeStrategy`

  - ### calcFacets

    public NumberRangePrefixTreeStrategy.Facets calcFacets(IndexReaderContext context, Bits topAcceptDocs, NumberRangePrefixTree.UnitNRShape start, NumberRangePrefixTree.UnitNRShape end) throws IOException
    Calculates facets between `start` and `end` to a detail level one greater than that provided by the arguments. For example providing March to October of 2014 would return facets to the day level of those months. This is just a convenience method.
    Throws:
      `IOException`
    See Also:
      - `calcFacets(IndexReaderContext, Bits, Shape, int)`

  - ### calcFacets

    public NumberRangePrefixTreeStrategy.Facets calcFacets(IndexReaderContext context, Bits topAcceptDocs, org.locationtech.spatial4j.shape.Shape facetRange, int level) throws IOException
    Calculates facets (aggregated counts) given a range shape (start-end span) and a level, which specifies the detail. To get the level of an existing shape, say a Calendar, call `NumberRangePrefixTree.toUnitShape(Object)` then call `NumberRangePrefixTree.UnitNRShape.getLevel()`. Facet computation is implemented by navigating the underlying indexed terms efficiently.
    Throws:
      `IOException`