ES|QL ST_GEOHASH function
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability 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. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability 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.
Serverless
Preview
Preview
Stack
Preview
9.2+
Preview since 9.2
Calculates the geohash of the supplied geo_point or geo_shape at the specified precision.
geometry- Expression of type
geo_pointorgeo_shape. Ifnull, the function returnsnull. Forgeo_shapeinputs all intersecting geohash cells are returned as multi-values. precision- Expression of type
integer. Ifnull, the function returnsnull. Valid values are between 1 and 12. bounds-
Optional bounds to filter the grid tiles, a
geo_shapeof typeBBOX. UseST_ENVELOPEif thegeo_shapeis of any other type.
Calculates the geohash of the supplied geo_point or geo_shape at the specified precision. For geo_shape inputs, all intersecting geohash 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 geohash_grid aggregation.
| geometry | precision | bounds | result |
|---|---|---|---|
| geo_point | integer | geo_shape | geohash |
| geo_point | integer | geohash | |
| 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 | geohash |
| 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 | geohash |
FROM airports
| EVAL geohash = ST_GEOHASH(location, 1)
| STATS
count = COUNT(geohash),
centroid = ST_CENTROID_AGG(location)
BY geohash
| WHERE count >= 10
| EVAL geohashString = TO_STRING(geohash)
| KEEP count, centroid, geohashString
| SORT count DESC, geohashString ASC
| count:long | centroid:geo_point | geohashString:keyword |
|---|---|---|
| 118 | POINT (-77.41857436454018 26.96522968734409) | d |
| 96 | POINT (23.181679135886952 27.295384635654045) | s |
| 94 | POINT (70.94076107503807 25.691916451026547) | t |
| 90 | POINT (-104.3941700803116 30.811849871650338) | 9 |
| 89 | POINT (18.71573683606942 53.165169130707305) | u |
| 85 | POINT (114.3722876966657 24.908398092505248) | w |
| 51 | POINT (-61.44522591713159 -22.87209844956284) | 6 |
| 38 | POINT (-9.429514887252529 25.497624435045413) | e |
| 34 | POINT (-111.8071846965262 52.464381378993174) | c |
| 30 | POINT (28.7045472683385 -14.706001980230212) | k |
| 28 | POINT (159.52750137208827 -25.555616633001982) | r |
| 22 | POINT (-4.410395708612421 54.90304926367985) | g |
| 21 | POINT (-69.40534970590046 50.93379438189523) | f |
| 17 | POINT (114.05526293222519 -10.898114638950895) | q |
| 16 | POINT (147.40052131412085 21.054660080408212) | x |
| 13 | POINT (63.64716878519035 54.37333276101317) | v |
| 12 | POINT (-39.53510569408536 -11.72166372067295) | 7 |