geohash-prefix.asciidoc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. [[geohash-prefix]]
  2. === `geohash_prefix`
  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. While the <<geohash,`geohash`>> option enables indexing the geohash that
  10. corresponds to the lat/lon point, at the specified
  11. <<geohash-precision,precision>>, the `geohash_prefix` option will also
  12. index all the enclosing cells as well.
  13. For instance, a geohash of `drm3btev3e86` will index all of the following
  14. terms: [ `d`, `dr`, `drm`, `drm3`, `drm3b`, `drm3bt`, `drm3bte`, `drm3btev`,
  15. `drm3btev3`, `drm3btev3e`, `drm3btev3e8`, `drm3btev3e86` ].
  16. The geohash prefixes can be used with the
  17. <<query-dsl-geohash-cell-query,`geohash_cell` query>> to find points within a
  18. particular geohash, or its neighbours:
  19. [source,js]
  20. --------------------------------------------------
  21. PUT my_index
  22. {
  23. "mappings": {
  24. "my_type": {
  25. "properties": {
  26. "location": {
  27. "type": "geo_point",
  28. "geohash_prefix": true,
  29. "geohash_precision": 6
  30. }
  31. }
  32. }
  33. }
  34. }
  35. --------------------------------------------------
  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. [source,js]
  40. --------------------------------------------------
  41. PUT my_index/my_type/1
  42. {
  43. "location": {
  44. "lat": 41.12,
  45. "lon": -71.34
  46. }
  47. }
  48. GET my_index/_search?fielddata_fields=location.geohash
  49. {
  50. "query": {
  51. "geohash_cell": {
  52. "location": {
  53. "lat": 41.02,
  54. "lon": -71.48
  55. },
  56. "precision": 4, <1>
  57. "neighbors": true <1>
  58. }
  59. }
  60. }
  61. --------------------------------------------------
  62. // CONSOLE
  63. // TEST[continued]