123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- [[geohash-precision]]
- === `geohash_precision`
- 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:
- [source,js]
- --------------------------------------------------
- PUT my_index
- {
- "mappings": {
- "my_type": {
- "properties": {
- "location": {
- "type": "geo_point",
- "geohash_prefix": true,
- "geohash_precision": 6 <1>
- }
- }
- }
- }
- }
- PUT my_index/my_type/1
- {
- "location": {
- "lat": 41.12,
- "lon": -71.34
- }
- }
- GET my_index/_search?fielddata_fields=location.geohash
- {
- "query": {
- "term": {
- "location.geohash": "drm3bt"
- }
- }
- }
- --------------------------------------------------
- // AUTOSENSE
- <1> A `geohash_precision` of 6 equates to geohash cells of approximately 1.26km x 0.6km
|