You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Ignacio Vera (JIRA)" <ji...@apache.org> on 2019/04/11 09:57:00 UTC

[jira] [Commented] (LUCENE-8736) LatLonShapePolygonQuery returning incorrect WITHIN results with shared boundaries

    [ https://issues.apache.org/jira/browse/LUCENE-8736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16815272#comment-16815272 ] 

Ignacio Vera commented on LUCENE-8736:
--------------------------------------

I have run my own benchmarks with this change and they look like:

|Approach||Shape||M hits/sec dev||M hits/sec base||M hits/sec diff||QPS dev||QPS base||QPS diff||Hit count dev||Hit count base||Hit count diff||
|points|box|77.42|75.92| 2%|78.78|77.25| 2%|221118844|221118844| 0%|
|points|polyRussia|15.99|18.42|-13%|4.56|5.25|-13%|3508846|3508846| 0%|
|points|poly 10|76.02|76.57|-1%|48.07|48.42|-1%|355809475|355809475| 0%|
|points|polyMedium|8.97|9.28|-3%|109.93|113.64|-3%|2693559|2693559| 0%|
|shapes|box|35.51|36.40|-2%|36.13|37.04|-2%|221118844|221118844| 0%|
|shapes|polyRussia|6.22|2.78|124%|1.77|0.79|124%|3508846|3508846| 0%|
|shapes|poly 10|26.91|19.73|36%|17.01|12.48|36%|355809475|355809475| 0%|
|shapes|polyMedium|2.71|1.06|156%|33.26|12.99|156%|2693559|2693559| 0%|

In addition I run the similar benchmarks and indexing the points as lines and as polygons:

|Approach||Shape||M hits/sec dev||M hits/sec base||M hits/sec diff||QPS dev||QPS base||QPS diff||Hit count dev||Hit count base||Hit count diff||
|line|box|35.42|35.56|-0%|35.91|36.05|-0%|221924270|221924270| 0%|
|line|polyRussia|3.65|2.52|45%|1.04|0.72|45%|3510913|3510913| 0%|
|line|poly 10|22.87|18.65|23%|14.43|11.76|23%|356664874|356664874| 0%|
|line|polyMedium|1.09|0.73|50%|12.70|8.49|50%|2820569|2820569| 0%|
|polygon|box|27.20|24.93| 9%|27.58|25.27| 9%|221925638|221925638| 0%|
|polygon|polyRussia|1.85|1.77| 4%|0.53|0.51| 4%|3511839|3511839| 0%|
|polygon|poly 10|13.11|14.05|-7%|8.26|8.85|-7%|357135836|357135836| 0%|
|polygon|polyMedium|0.49|0.49| 1%|5.67|5.62| 1%|2857655|2857655| 0%|


+1. I like this approach. Benchmarks show  that adjusting the logic depending on the type of triangle as it really speeds up points and lines with a small hit on polygons (which might be due to the change in how contains is computed). 
Could we add a comment when we call tree#crossesBox regarding why we choose to include the boundaries? 



> LatLonShapePolygonQuery returning incorrect WITHIN results with shared boundaries
> ---------------------------------------------------------------------------------
>
>                 Key: LUCENE-8736
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8736
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Nicholas Knize
>            Priority: Major
>         Attachments: LUCENE-8736.patch, LUCENE-8736.patch, adaptive-decoding.patch
>
>
> Triangles that are {{WITHIN}} a target polygon query that also share a boundary with the polygon are incorrectly reported as {{CROSSES}} instead of {{INSIDE}}. This leads to incorrect {{WITHIN}} query results  as demonstrated in the following test:
> {code:java}
>   public void testWithinFailure() throws Exception {
>     Directory dir = newDirectory();
>     RandomIndexWriter w = new RandomIndexWriter(random(), dir);
>     // test polygons:
>     Polygon indexPoly1 = new Polygon(new double[] {4d, 4d, 3d, 3d, 4d}, new double[] {3d, 4d, 4d, 3d, 3d});
>     Polygon indexPoly2 = new Polygon(new double[] {2d, 2d, 1d, 1d, 2d}, new double[] {6d, 7d, 7d, 6d, 6d});
>     Polygon indexPoly3 = new Polygon(new double[] {1d, 1d, 0d, 0d, 1d}, new double[] {3d, 4d, 4d, 3d, 3d});
>     Polygon indexPoly4 = new Polygon(new double[] {2d, 2d, 1d, 1d, 2d}, new double[] {0d, 1d, 1d, 0d, 0d});
>     // index polygons:
>     Document doc;
>     addPolygonsToDoc(FIELDNAME, doc = new Document(), indexPoly1);
>     w.addDocument(doc);
>     addPolygonsToDoc(FIELDNAME, doc = new Document(), indexPoly2);
>     w.addDocument(doc);
>     addPolygonsToDoc(FIELDNAME, doc = new Document(), indexPoly3);
>     w.addDocument(doc);
>     addPolygonsToDoc(FIELDNAME, doc = new Document(), indexPoly4);
>     w.addDocument(doc);
>     ///// search //////
>     IndexReader reader = w.getReader();
>     w.close();
>     IndexSearcher searcher = newSearcher(reader);
>     Polygon[] searchPoly = new Polygon[] {new Polygon(new double[] {4d, 4d, 0d, 0d, 4d}, new double[] {0d, 7d, 7d, 0d, 0d})};
>     Query q = LatLonShape.newPolygonQuery(FIELDNAME, QueryRelation.WITHIN, searchPoly);
>     assertEquals(4, searcher.count(q));
>     IOUtils.close(w, reader, dir);
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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