Type to search.

ES|QL ST_GEOHEX function

Serverless Preview

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Preview

    This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply.

Serverless interfaces and procedures might differ from classic Elastic Stack deployments.

Stack Preview 9.2+

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Preview since 9.2

    This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply.

Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

Calculates the geohex (H3 cell-id) of the supplied geo_point or geo_shape at the specified precision.

Embedded
Embedded
geometry
Expression of type geo_point or geo_shape. If null, the function returns null. For geo_shape inputs all intersecting H3 cells are returned as multi-values.
precision
Expression of type integer. If null, the function returns null. Valid values are between 0 and 15.
bounds

Optional bounds to filter the grid tiles, a geo_shape of type BBOX. Use ST_ENVELOPE if the geo_shape is of any other type.

Calculates the geohex, the H3 cell-id, of the supplied geo_point or geo_shape at the specified precision. For geo_shape inputs, all intersecting H3 cells are returned as multi-values. The result is long encoded. Use TO_STRING to convert the result to a string, TO_LONG to convert it to a long, or TO_GEOSHAPE to calculate the geo_shape bounding geometry. These functions are related to the geo_grid query and the geohex_grid aggregation.

geometry precision bounds result
geo_point integer geo_shape geohex
geo_point integer geohex
geo_shape The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Planned We plan to add this functionality in a future Elastic Stack update. Subject to changes. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes. integer geo_shape geohex
geo_shape The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Planned We plan to add this functionality in a future Elastic Stack update. Subject to changes. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes. integer geohex
ES|QL
FROM airports
| EVAL geohex = ST_GEOHEX(location, 1)
| STATS
    count = COUNT(geohex),
    centroid = ST_CENTROID_AGG(location)
      BY geohex
| WHERE count >= 10
| EVAL geohexString = TO_STRING(geohex)
| KEEP count, centroid, geohexString
| SORT count DESC, geohexString ASC
count:long centroid:geo_point geohexString:keyword
22 POINT (7.250850197689777 48.21363834643059) 811fbffffffffff
18 POINT (-80.64959161449224 40.04119813675061) 812abffffffffff
17 POINT (-0.7606179875266903 52.86413913565304) 81197ffffffffff
13 POINT (22.53157936179867 41.98255742864254) 811efffffffffff
13 POINT (78.30096947387435 26.073904778951636) 813dbffffffffff
12 POINT (-76.39781514415517 45.16300531569868) 812bbffffffffff
12 POINT (-100.30120467301458 20.114154297625646) 8149bffffffffff
11 POINT (18.037187419831753 48.66540593306788) 811e3ffffffffff
11 POINT (-83.42379064553164 33.18388901439241) 8144fffffffffff
11 POINT (-99.4237939513881 27.100012352774765) 8148bffffffffff
10 POINT (128.01009018346667 35.8699960866943) 8130fffffffffff