WARNING: Version 2.4 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
geohash
editgeohash
editGeohashes are a form of lat/lon encoding which divides the earth up into a grid. Each cell in this grid is represented by a geohash string. Each cell in turn can be further subdivided into smaller cells which are represented by a longer string. So the longer the geohash, the smaller (and thus more accurate) the cell is.
Because geohashes are just strings, they can be stored in an inverted index like any other string, which makes querying them very efficient.
If you enable the geohash
option, a geohash
“sub-field” will be indexed
as, eg .geohash
. The length of the geohash is controlled by the
geohash_precision
parameter.
If the geohash_prefix
option is enabled, the geohash
option will be enabled automatically.
For example:
PUT my_index { "mappings": { "my_type": { "properties": { "location": { "type": "geo_point", "geohash": true } } } } } PUT my_index/my_type/1 { "location": { "lat": 41.12, "lon": -71.34 } } GET my_index/_search?fielddata_fields=location.geohash { "query": { "prefix": { "location.geohash": "drm3b" } } }
A |
|
The geohash can be retrieved with |
|
A |
A prefix
query on geohashes is expensive. Instead, consider using the
geohash_prefix
to pay the expense once at index time
instead of on every query.