⚡ ElasticsearchBook.com is powered by:
- Notion-Paywall.com (Password-protect your Notion pages)
- in cooperation with Spatialized.io (Elasticsearch & Google Maps consulting)
- and Garages-Near-Me.com (Effortless long-term parking across Germany)
Geographical objects and shapes are supported in ES through these field types:
- GEO POINTS → latitude/longitude pairs or geo hashes. Primarily used for:
- finding locations within a bounding box, within a certain distance of a central point, within a polygon, or within a geo_shape query
- aggregating locations geographically or by distance from a central point,
- integrating distance into a document’s relevance score
- and sorting documents by distance.
- GEO SHAPES → select GeoJSON and WKT entities. Used for:
geo_shapedocuments using the spatial relations
- SHAPES → arbitrary
x, ycartesian shapes Only available within X-Pack — a closed-source collection of features that's part of an official Elasticsearch Subscription.
The third dimension (z-value) in any of the above field types is also accepted but only the latitude and longitude values will be indexed — the third dimension is ignored!
Coordinate Accuracy & Precision
People often ask how many coordinate decimal places they should store.
Let's clarify that by borrowing from this GIS Stack Exchange thread and this answer by whuber:
- Accuracy is the tendency of your measurements to agree with the true values.
- Precision is the degree to which your measurements pin down an actual value.
I'm not going to get into the accuracy part and will rather focus on precision — here's a summary of what each digit in a decimal degree signifies:
- The sign tells us whether we are north or south, east or west on the globe (+ N/E, - S/W).
- A nonzero hundreds digit tells us we're using longitude, not latitude! See below — the x-axis represents the longitude, the y-axis the latitude:
North (+90) | | (-180) West ---+--- East (+180) | | South (-90)