David Smiley commented on LUCENE-8126:

Nice to finally see this in!

I was trying to use this from Solr to try it out.  I went to one of our tests 
-- TestSolr4Spatial2 and ran it, after changing schema-spatial.xml so that the 
srtpgeom_geo3d field type looked as follows:
  <fieldType name="srptgeom_geo3d" class="solr.RptWithGeometrySpatialField"
             spatialContextFactory="Geo3D" planetModel="wgs84"

But it doesn't work when given a non-point shape to index because of the 
default pruneLeafyBranches setting in RecursivePrefixTreeStrategy which only 
works with "LegacyPrefixTree" grids (the other 3 do).  Hmm.  Looking at the 
notes I put here long ago it seems that RPT Strategy should be modified to have 
it's constructor set {{this.pruneLeafyBranches = (grid instanceof 

The actual exception thrown is here recursiveTraverseAndPrune:
  /** Returns true if cell was added as a leaf. If it wasn't it recursively 
descends. */
  private boolean recursiveTraverseAndPrune(Cell cell, Shape shape, int 
detailLevel, List<Cell> result) {
    // Important: this logic assumes Cells don't share anything with other 
cells when
    // calling cell.getNextLevelCells(). This is only true for LegacyCell.
    if (!(cell instanceof LegacyCell))
      throw new IllegalStateException("pruneLeafyBranches must be disabled for 
use with grid "+grid);
The comment about "This is only true for LegacyCell" should perhaps read "We 
know this is so for LegacyCell but don't know for other things."  Do you know 
if it's true for S2 [~ivera]?  Perhaps regardless better safe to not do this 
than do this pruning when it's not safe.

> Spatial prefix tree based on S2 geometry
> ----------------------------------------
>                 Key: LUCENE-8126
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8126
>             Project: Lucene - Core
>          Issue Type: New Feature
>          Components: modules/spatial-extras
>            Reporter: Ignacio Vera
>            Assignee: Ignacio Vera
>            Priority: Major
>         Attachments: SPT-cell.pdf, SPT-query.jpeg
>          Time Spent: 50m
>  Remaining Estimate: 0h
> Hi [~dsmiley],
> I have been working on a prefix tree based on goggle S2 geometry 
> (https://s2geometry.io/) to be used mainly with Geo3d shapes with very 
> promising results, in particular for complex shapes (e.g polygons). Using 
> this pixelization scheme reduces the size of the index, improves the 
> performance of the queries and reduces the loading time for non-point shapes. 
> If you are ok with this contribution and before providing any code I would 
> like to understand what is the correct/prefered approach:
> 1) Add new depency to the S2 library 
> (https://mvnrepository.com/artifact/io.sgr/s2-geometry-library-java). It has 
> Apache 2.0 license so it should be ok.
> 2) Create a utility class with all methods necessary to navigate the S2 tree 
> and create shapes from S2 cells (basically port what we need from the library 
> into Lucene).
> What do you think?

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to