Skip to content

Support geohash, geotile and geohex grid types #129581

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

craigtaverner
Copy link
Contributor

@craigtaverner craigtaverner commented Jun 17, 2025

The PR at #125143 added support for ST_GEOHASH, ST_GEOTILE and ST_GEOHEX. However, since it used long as the internal type for the grid id, there was need for many additional functions for converting the long to and from keyword as well as generating geo_shape cell bounds for map display. Each pf these involved many more files (for the functions, their docs and the generated evaluators). With inspiration from PostGIS we decided to take a different direction, and instead use a new internal type for each grid:

  • geohash for the ST_GEOHASH function, created from literal using either TO_GEOHASH(hash) or hash::geohash
  • geotile for the ST_GEOTILE function, created from literal using either TO_GEOTILE(tile) or tile::geotile
  • geohex for the ST_GEOHEX function, created from literal using either TO_GEOHEX(h3) or h3::geohex

This also leads to much stricter type checking as we can no longer use the long as a plain long in all functions that accept longs, or inadvertently using a geohash in a geotile function. However, the addition of new types involves a lot of boilerplate, especially considering the large number of functions that operate on all types, and need to be informed of the existence of these three new types.

One of the main goals of this work was to also support the concept of a geogrid search. This means "find all documents that intersect a grid cell", similar to the Query DSL version. This is achieved by enabling the use of these three new types in the ST_INTERSECTS function, so a query like this would satisfy the requirement:

FROM airports
| WHERE ST_INTERSECTS(location, "3/4/3"::geotile)

@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 v9.1.0 labels Jun 17, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

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

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) v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants