ES|QL ST_DISTANCE function
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability This functionality is generally available and ready for production usage. 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 generally available and ready for production usage. 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
Generally available
Stack
Generally available
Computes the distance between two points.
geomA- Expression of type
geo_pointorcartesian_point. Ifnull, the function returnsnull. geomB-
Expression of type
geo_pointorcartesian_point. Ifnull, the function returnsnull. The second parameter must also have the same coordinate system as the first. This means it is not possible to combinegeo_pointandcartesian_pointparameters.
Computes the distance between two points. For cartesian geometries, this is the pythagorean distance in the same units as the original coordinates. For geographic geometries, this is the circular distance along the great circle in meters.
| geomA | geomB | result |
|---|---|---|
| cartesian_point | cartesian_point | double |
| geo_point | geo_point | double |
FROM airports
| WHERE abbrev == "CPH"
| EVAL distance = ST_DISTANCE(location, city_location)
| KEEP abbrev, name, location, city_location, distance
| abbrev:k | name:text | location:geo_point | city_location:geo_point | distance:d |
|---|---|---|---|---|
| CPH | Copenhagen | POINT(12.6493508684508 55.6285017221528) | POINT(12.5683 55.6761) | 7339.573896618216 |