Lucene - Core
  1. Lucene - Core
  2. LUCENE-4594

Spatial PrefixTreeStrategy shouldn't index center-points with shapes together

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0, 6.0
    • Fix Version/s: 4.1, 6.0
    • Component/s: modules/spatial
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      The Spatial PrefixTreeStrategy will index the center-point of a non-point shape it is given to index, in addition to the shape itself of course. The rationale was that this point could be picked up by PointPrefixTreeFieldCacheProvider for distance/sorting. However this approach is buggy since the distinction of grid cells between the center point and the shape itself is lost when the shape gets indexed down to max-levels precision – each grid cell therein appears to be another point that needs to be brought into memory. It's also possible that the shape is a LineString or some other non-trivial shape in which its center point isn't actually in the shape.

      Even if you knew this problem would never happen, I think you're better off indexing center points into another spatial field if you want them. Perhaps arguably this strategy could do that internally? Wether or not that ends up happening, I just want to remove the problematic behavior now.

        Activity

        Hide
        David Smiley added a comment -

        Attached is a patch. Pretty simple as it just removes the undesired behavior.

        Back compat CHANGES.txt entry:

        * LUCENE-4594: Spatial PrefixTreeStrategy no longer indexes center points of
          non-point shapes.  If you want to call makeDistanceValueSource() based on
          shape centers, you need to do this yourself in another spatial field.
          (David Smiley)
        

        Bug CHANGES.txt entry:

        * LUCENE-4594: Spatial PrefixTreeStrategy would index center-points in addition
          to the shape to index if it was non-point, in the same field.  But sometimes
          the center-point isn't actually in the shape (consider a LineString), and for
          highly precise shapes it could cause makeDistanceValueSource's cache to load
          parts of the shape's boundary erroneously too.  So center points aren't
          indexed any more; you should use another spatial field. (David Smiley)
        

        If there are no objections or discussion then I intend to commit this Monday.

        Show
        David Smiley added a comment - Attached is a patch. Pretty simple as it just removes the undesired behavior. Back compat CHANGES.txt entry: * LUCENE-4594: Spatial PrefixTreeStrategy no longer indexes center points of non-point shapes. If you want to call makeDistanceValueSource() based on shape centers, you need to do this yourself in another spatial field. (David Smiley) Bug CHANGES.txt entry: * LUCENE-4594: Spatial PrefixTreeStrategy would index center-points in addition to the shape to index if it was non-point, in the same field. But sometimes the center-point isn't actually in the shape (consider a LineString), and for highly precise shapes it could cause makeDistanceValueSource's cache to load parts of the shape's boundary erroneously too. So center points aren't indexed any more; you should use another spatial field. (David Smiley) If there are no objections or discussion then I intend to commit this Monday.
        Hide
        Commit Tag Bot added a comment -

        [trunk commit] David Wayne Smiley
        http://svn.apache.org/viewvc?view=revision&revision=1419630

        LUCENE-4594: PrefixTreeStrategy should not index center points

        Show
        Commit Tag Bot added a comment - [trunk commit] David Wayne Smiley http://svn.apache.org/viewvc?view=revision&revision=1419630 LUCENE-4594 : PrefixTreeStrategy should not index center points
        Hide
        Commit Tag Bot added a comment -

        [branch_4x commit] David Wayne Smiley
        http://svn.apache.org/viewvc?view=revision&revision=1419634

        LUCENE-4594: PrefixTreeStrategy should not index center points

        Show
        Commit Tag Bot added a comment - [branch_4x commit] David Wayne Smiley http://svn.apache.org/viewvc?view=revision&revision=1419634 LUCENE-4594 : PrefixTreeStrategy should not index center points

          People

          • Assignee:
            David Smiley
            Reporter:
            David Smiley
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development