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

Support spatial distance search in ES|QL (ST_DISTANCE) #108212

Closed
8 tasks done
craigtaverner opened this issue May 2, 2024 · 3 comments
Closed
8 tasks done

Support spatial distance search in ES|QL (ST_DISTANCE) #108212

craigtaverner opened this issue May 2, 2024 · 3 comments
Assignees
Labels
:Analytics/ES|QL AKA ESQL :Analytics/Geo Indexing, search aggregations of geo points and shapes >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@craigtaverner
Copy link
Contributor

craigtaverner commented May 2, 2024

Description

The Elasticsearch _search API supports distance filtering and sorting:

In PostGIS there are two related functions:

These features can be implemented in ES|QL, but we believe we do not need to implement both functions, as we can perform Lucene-pushdown optimization identically in both cases, so we'll implement the more generic function only: double ST_DISTANCE(geomA, geomB).

This can be used for calculating a distance, filter and sorting based on the context in the query:

Distance calculations

FROM airports
| EVAL distance = ST_DISTANCE(location, city_location)

Filtering results

FROM airports
| WHERE ST_DISTANCE(location, TO_GEOPOINT("POINT(12 55)")) < 500000

Sorting results

FROM airports
| EVAL distance = ST_DISTANCE(location, TO_GEOPOINT("POINT(12 55)"))
| SORT distance ASC

Tasks

  1. :Analytics/ES|QL :Analytics/Geo >enhancement Team:Analytics
    craigtaverner
@craigtaverner craigtaverner added >enhancement :Analytics/Geo Indexing, search aggregations of geo points and shapes Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL labels May 2, 2024
@elasticsearchmachine
Copy link
Collaborator

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

@craigtaverner
Copy link
Contributor Author

We should also keep in mind use cases involving speed, as discussed at #108332 (comment)

@craigtaverner craigtaverner changed the title Support spatial distance search in ES|QL (ST_DWITHIN, ST_DISTANCE) Support spatial distance search in ES|QL (ST_DISTANCE) Jun 20, 2024
@craigtaverner
Copy link
Contributor Author

Since the lucene pushdown for spatial sort has it's own issue, now moved to 8.16, we'll mark this main issue as DONE for 8.15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL :Analytics/Geo Indexing, search aggregations of geo points and shapes >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

2 participants