iverase commented on issue #762: LUCENE-8903: Add LatLonShape point query
URL: https://github.com/apache/lucene-solr/pull/762#issuecomment-508639264
 
 
   Going a bit more in detail, I wrote the following test to prove a difference 
between LatLonPoint and LatLonShape:
   
   ```
    public void testPointShapeEquivalence() throws Exception {
       Directory dir = newDirectory();
       RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
       Document document = new Document();
       BaseLatLonShapeTestCase.Point p = (BaseLatLonShapeTestCase.Point) 
BaseLatLonShapeTestCase.ShapeType.POINT.nextShape();
       Polygon polygon = GeoTestUtil.nextPolygon();
   
       Field[] fields = LatLonShape.createIndexableFields("LatLonShape", 
polygon);
       for (Field f : fields) {
         document.add(f);
       }
       LatLonPoint latLonPoint = new LatLonPoint("LatLonPoint", p.lat, p.lon);
       document.add(latLonPoint);
       writer.addDocument(document);
   
       //// search
       IndexReader r = writer.getReader();
       writer.close();
       IndexSearcher s = newSearcher(r);
   
       // search both and check same result
       Query q1 = LatLonShape.newPointQuery("LatLonShape", 
QueryRelation.INTERSECTS, p.lat, p.lon);
       Query q2 = LatLonPoint.newPolygonQuery("LatLonPoint", polygon);
       assertEquals(s.count(q1), s.count(q2));
       IOUtils.close(r, dir);
     }
   ```
   
   The test basically index a shape and make a point query and at the same time 
it index the same point a make a polygon query with the same polygon. It will 
eventually fail because in LatLonShape, both polygon and point work on the 
encoding space. On the other hand for LatLonPoint, the query polygon does not 
work on the encoding space.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to