2015-08-06 11:24:29 -04:00
|
|
|
[[geohash-prefix]]
|
|
|
|
=== `geohash_prefix`
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
While the <<geohash,`geohash`>> option enables indexing the geohash that
|
|
|
|
corresponds to the lat/lon point, at the specified
|
|
|
|
<<geohash-precision,precision>>, the `geohash_prefix` option will also
|
|
|
|
index all the enclosing cells as well.
|
|
|
|
|
|
|
|
For instance, a geohash of `drm3btev3e86` will index all of the following
|
|
|
|
terms: [ `d`, `dr`, `drm`, `drm3`, `drm3b`, `drm3bt`, `drm3bte`, `drm3btev`,
|
|
|
|
`drm3btev3`, `drm3btev3e`, `drm3btev3e8`, `drm3btev3e86` ].
|
|
|
|
|
|
|
|
The geohash prefixes can be used with the
|
|
|
|
<<query-dsl-geohash-cell-query,`geohash_cell` query>> to find points within a
|
|
|
|
particular geohash, or its neighbours:
|
|
|
|
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
PUT my_index
|
|
|
|
{
|
|
|
|
"mappings": {
|
|
|
|
"my_type": {
|
|
|
|
"properties": {
|
|
|
|
"location": {
|
|
|
|
"type": "geo_point",
|
|
|
|
"geohash_prefix": true,
|
|
|
|
"geohash_precision": 6
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-23 13:43:35 -04:00
|
|
|
--------------------------------------------------
|
2016-09-06 10:46:50 -04:00
|
|
|
// CONSOLE
|
2016-08-23 13:43:35 -04:00
|
|
|
// 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
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2015-08-06 11:24:29 -04:00
|
|
|
PUT my_index/my_type/1
|
|
|
|
{
|
|
|
|
"location": {
|
|
|
|
"lat": 41.12,
|
|
|
|
"lon": -71.34
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GET my_index/_search?fielddata_fields=location.geohash
|
|
|
|
{
|
|
|
|
"query": {
|
|
|
|
"geohash_cell": {
|
|
|
|
"location": {
|
|
|
|
"lat": 41.02,
|
|
|
|
"lon": -71.48
|
|
|
|
},
|
|
|
|
"precision": 4, <1>
|
|
|
|
"neighbors": true <1>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2016-05-09 09:42:23 -04:00
|
|
|
// CONSOLE
|
2016-08-23 13:43:35 -04:00
|
|
|
// TEST[continued]
|