elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
1.12k stars 24.83k forks source link

ST_WITHIN on multi-valued cartesian points returns false positives from lucene pushdown #112102

Closed craigtaverner closed 2 months ago

craigtaverner commented 2 months ago

The issue at https://github.com/elastic/elasticsearch/issues/110830 describes how Lucene pushdown for spatial predicates does not match the compute engine results. This is mostly because we support multi-values in Lucene pushdown, but not in the compute engine. The fix at https://github.com/elastic/elasticsearch/pull/112063 enabled multi-value support in the compute engine, but exposes an additional bug.

For cartesian multi-value points, the lucene pushdown for ST_WITHIN acts like ST_INTERSECTS in that it returns true if ANY of the points intersect the test geometry, instead of requiring ALL points to intersect the test geometry.

To reproduce this we have failing tests:

The latter simply creates explicit tests of single and multivalued points, where it is clear which are merely intersecting or entirely within the test polygon. This works fine for geo_point, but fails for cartesian_point with multi-values where the points are partially within the polygon.

elasticsearchmachine commented 2 months ago

Pinging @elastic/es-analytical-engine (Team:Analytics)

craigtaverner commented 2 months ago

Fixed by https://github.com/elastic/elasticsearch/pull/112204