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_DWITHIN, ST_DISTANCE) #108212

Open
9 tasks
craigtaverner opened this issue May 2, 2024 · 2 comments
Open
9 tasks
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

Description

The Elasticsearch _search API supports distance filtering and sorting:

In PostGIS there are two related functions:

  • ST_DWITHIN for filtering by distance
  • ST_DISTANCE for calculating a distance, also usable for sorting

These features can be implemented in ES|QL through two overlapping OGC compliant functions:

  • boolean ST_DWITHIN(geomA, geomB, distance) for filtering by distance
  • float ST_DISTANCE(geomA, geomB) for calculating a distance, filtering and sorting

Sorting example:

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

See the PostGIS documentation for inspiration:

Tasks

@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)

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