Skip to content

ES|QL Support for ST_GEOHASH, ST_GEOTILE and ST_GEOHEX #125143

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

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

craigtaverner
Copy link
Contributor

@craigtaverner craigtaverner commented Mar 18, 2025

In support of the feature request at #123903

Checklist:

  • Prototype
    • Implement basic ST_GEOHASH on points
    • Add support for optional bounds parameter
    • Support multivalues (incoming and outgoing)
    • Add support for ST_GEOTILE
    • Add support for ST_GEOHEX
  • Productize:
    • Use bounded predicates to filter by tile, not geometry
      • Use GeoTileBoundedPredicate for correct geotile bounds filtering
      • Use GeohashBoundedPredicate for correct geohash bounds filtering
      • Copy GeoHexCellIdSource.GeoHexPredicate and H3SphericalUtil classes into esql module and use them for correct H3 bounds filtering
    • Refine API
      • Change functions to return long grid-ids instead of keyword for performance and add new functions for keyword alternatives
      • Create conversion functions between long and keyword versions of the grid-ids
      • Create functions to generate geometries from the grid-ids
    • Additional refinements
      • Add unit tests and generate docs
      • Check input parameters for validity (eg. negative precision)
      • Errors tests
      • Precision range validation
      • Non-foldable bounds
      • Docs links to query dsl
  • Extra features (could be done here or in later PRs)
    • Expand support to geo_shape fields
    • Add pushdown to Lucene for grid aggregations

}

protected static BytesRef calculateGeotile(Point point, int precision, Rectangle bounds) {
// For points, filtering the point is as good as filtering the tile
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. The current code was a quick-and dirty placeholder for the draft PR. I'll definitely switch over to the better code you suggest.

@iverase
Copy link
Contributor

iverase commented Apr 9, 2025

I was trying queries like:

ROW location=TO_GEOPOINT("POINT(0 0)")| EVAL hex=ST_GEOHEX(location, -1)

In case of geohex and geotile we provide a good error although looking into the stack trace it feels to me that we are not checking the input while parsing and we only fail when trying to apply the function to the point. More over, for geohash it does not throw an error.

Let's improve the checking of input parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants