OpenSearch/docs/reference/mapping/params/geohash-precision.asciidoc

73 lines
2.1 KiB
Plaintext

[[geohash-precision]]
=== `geohash_precision`
deprecated[5.0.0, Will be removed in the next major version.]
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.
For example, using this mapping:
[source,js]
--------------------------------------------------
PUT my_index
{
"mappings": {
"my_type": {
"properties": {
"location": {
"type": "geo_point",
"geohash_prefix": true,
"geohash_precision": 6 <1>
}
}
}
}
}
--------------------------------------------------
// 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]
You can issue this index and query:
[source,js]
--------------------------------------------------
PUT my_index/my_type/1?refresh
{
"location": {
"lat": 41.12,
"lon": -71.34
}
}
GET my_index/_search?fielddata_fields=location.geohash
{
"query": {
"term": {
"location.geohash": "drm3bt"
}
}
}
--------------------------------------------------
// CONSOLE
// TEST[continued]
<1> A `geohash_precision` of 6 equates to geohash cells of approximately 1.26km x 0.6km