geohash-precision.asciidoc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. [[geohash-precision]]
  2. === `geohash_precision`
  3. deprecated[5.0.0, Will be removed in the next major version.]
  4. Geohashes are a form of lat/lon encoding which divides the earth up into
  5. a grid. Each cell in this grid is represented by a geohash string. Each
  6. cell in turn can be further subdivided into smaller cells which are
  7. represented by a longer string. So the longer the geohash, the smaller
  8. (and thus more accurate) the cell is.
  9. The `geohash_precision` setting controls the length of the geohash that is
  10. indexed when the <<geohash,`geohash`>> option is enabled, and the maximum
  11. geohash length when the <<geohash-prefix,`geohash_prefix`>> option is enabled.
  12. It accepts:
  13. * a number between 1 and 12 (default), which represents the length of the geohash.
  14. * a <<distance-units,distance>>, e.g. `1km`.
  15. If a distance is specified, it will be translated to the smallest
  16. geohash-length that will provide the requested resolution.
  17. For example, using this mapping:
  18. [source,js]
  19. --------------------------------------------------
  20. PUT my_index
  21. {
  22. "mappings": {
  23. "my_type": {
  24. "properties": {
  25. "location": {
  26. "type": "geo_point",
  27. "geohash_prefix": true,
  28. "geohash_precision": 6 <1>
  29. }
  30. }
  31. }
  32. }
  33. }
  34. --------------------------------------------------
  35. // CONSOLE
  36. // TEST[warning:geo_point geohash_precision parameter is deprecated and will be removed in the next major release]
  37. // TEST[warning:geo_point geohash_prefix parameter is deprecated and will be removed in the next major release]
  38. // TEST[warning:geo_point geohash parameter is deprecated and will be removed in the next major release]
  39. You can issue this index and query:
  40. [source,js]
  41. --------------------------------------------------
  42. PUT my_index/my_type/1?refresh
  43. {
  44. "location": {
  45. "lat": 41.12,
  46. "lon": -71.34
  47. }
  48. }
  49. GET my_index/_search?fielddata_fields=location.geohash
  50. {
  51. "query": {
  52. "term": {
  53. "location.geohash": "drm3bt"
  54. }
  55. }
  56. }
  57. --------------------------------------------------
  58. // CONSOLE
  59. // TEST[continued]
  60. <1> A `geohash_precision` of 6 equates to geohash cells of approximately 1.26km x 0.6km