Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESQL: Support ST_DISJOINT #107007

Merged
merged 13 commits into from
Apr 8, 2024
Merged

Conversation

craigtaverner
Copy link
Contributor

@craigtaverner craigtaverner commented Apr 2, 2024

Following on from the ESQL spatial query work already done:

We add the fourth and final of the four Lucene-backed spatial search predicates: ST_DISJOINT. This is essentially the opposite of ST_INTERSECTS such that if two geometries intersect, they are not disjoint, and if they do not intersect, they are disjoint. The PostGIS documentation can be comared at https://postgis.net/docs/ST_Disjoint.html

@craigtaverner craigtaverner added >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL labels Apr 2, 2024
@elasticsearchmachine
Copy link
Collaborator

Hi @craigtaverner, I've created a changelog YAML for you.

@craigtaverner craigtaverner marked this pull request as ready for review April 3, 2024 10:01
@craigtaverner craigtaverner requested a review from iverase April 3, 2024 10:01
@elasticsearchmachine
Copy link
Collaborator

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

// Should never be null, but can be an empty geometry
return new MatchNoDocsQuery();
// Should never be null, but could be an empty geometry
return new MatchNoDocsQuery("Empty geometry");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct for disjoint?

Copy link
Contributor

@iverase iverase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment for empty geometries that I think needs addressing

…ption

In lucene code only LineString can be empty, but in Elasticsearch even that is not allowed, resulting in parsing errors. So we cannot get to this code in the lucene push-down and now throw an error instead. The tests now assert on the warnings.

Note that for any predicate DISJOINT and INTERSECTS alike, the predicate fails, because the parsing error results in null, the function returns null, the predicate interprets this as false, and no documents match. This null-in-null-out rule means that DISJOINT and INTERSECTS give the same answer on invalid geometries.
@craigtaverner craigtaverner merged commit a7b3839 into elastic:main Apr 8, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Spatial Search in ES|QL (ST_INTERSECTS, ST_CONTAINS, ST_WITHIN and ST_DISJOINT)
3 participants