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

75 lines
2.1 KiB
Plaintext
Raw Normal View History

[[geohash-prefix]]
=== `geohash_prefix`
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.
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
}
}
}
}
}
--------------------------------------------------
// 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]
[source,js]
--------------------------------------------------
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>
}
}
}
--------------------------------------------------
// CONSOLE
// TEST[continued]