2015-08-06 11:24:29 -04:00
|
|
|
[[geohash-precision]]
|
|
|
|
=== `geohash_precision`
|
|
|
|
|
2016-08-23 13:43:35 -04:00
|
|
|
deprecated[5.0.0, Will be removed in the next major version.]
|
|
|
|
|
2015-08-06 11:24:29 -04:00
|
|
|
Geohashes 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.
|
|
|
|
|
|
|
|
The `geohash_precision` setting controls the length of the geohash that is
|
|
|
|
indexed when the <<geohash,`geohash`>> option is enabled, and the maximum
|
|
|
|
geohash length when the <<geohash-prefix,`geohash_prefix`>> option is enabled.
|
|
|
|
|
|
|
|
It accepts:
|
|
|
|
|
|
|
|
* a number between 1 and 12 (default), which represents the length of the geohash.
|
|
|
|
* a <<distance-units,distance>>, e.g. `1km`.
|
|
|
|
|
|
|
|
If a distance is specified, it will be translated to the smallest
|
|
|
|
geohash-length that will provide the requested resolution.
|
|
|
|
|
2016-08-23 13:43:35 -04:00
|
|
|
For example, using this mapping:
|
2015-08-06 11:24:29 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
PUT my_index
|
|
|
|
{
|
|
|
|
"mappings": {
|
|
|
|
"my_type": {
|
|
|
|
"properties": {
|
|
|
|
"location": {
|
|
|
|
"type": "geo_point",
|
|
|
|
"geohash_prefix": true,
|
|
|
|
"geohash_precision": 6 <1>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-23 13:43:35 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[warning:geo_point geohash_precision parameter is deprecated and will be removed in the next major release]
|
|
|
|
// TEST[warning:geo_point geohash_prefix parameter is deprecated and will be removed in the next major release]
|
|
|
|
// TEST[warning:geo_point geohash parameter is deprecated and will be removed in the next major release]
|
2015-08-06 11:24:29 -04:00
|
|
|
|
2016-08-23 13:43:35 -04:00
|
|
|
You can issue this index and query:
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
PUT my_index/my_type/1?refresh
|
2015-08-06 11:24:29 -04:00
|
|
|
{
|
|
|
|
"location": {
|
|
|
|
"lat": 41.12,
|
|
|
|
"lon": -71.34
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GET my_index/_search?fielddata_fields=location.geohash
|
|
|
|
{
|
|
|
|
"query": {
|
|
|
|
"term": {
|
|
|
|
"location.geohash": "drm3bt"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
--------------------------------------------------
|
2016-05-09 09:42:23 -04:00
|
|
|
// CONSOLE
|
2016-08-23 13:43:35 -04:00
|
|
|
// TEST[continued]
|
|
|
|
|
2015-08-06 11:24:29 -04:00
|
|
|
<1> A `geohash_precision` of 6 equates to geohash cells of approximately 1.26km x 0.6km
|