geohash-cell-query.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. [[query-dsl-geohash-cell-query]]
  2. === Geohash Cell Query
  3. The `geohash_cell` query provides access to a hierarchy of geohashes.
  4. By defining a geohash cell, only <<geo-point,geopoints>>
  5. within this cell will match this filter.
  6. To get this filter work all prefixes of a geohash need to be indexed. In
  7. example a geohash `u30` needs to be decomposed into three terms: `u30`,
  8. `u3` and `u`. This decomposition must be enabled in the mapping of the
  9. <<geo-point,geopoint>> field that's going to be filtered by
  10. setting the `geohash_prefix` option:
  11. [source,js]
  12. --------------------------------------------------
  13. PUT /my_index
  14. {
  15. "mappings" : {
  16. "location": {
  17. "properties": {
  18. "pin": {
  19. "type": "geo_point",
  20. "geohash": true,
  21. "geohash_prefix": true,
  22. "geohash_precision": 10
  23. }
  24. }
  25. }
  26. }
  27. }
  28. --------------------------------------------------
  29. // CONSOLE
  30. // TEST[warning:geo_point geohash parameter is deprecated and will be removed in the next major release]
  31. // TEST[warning:geo_point geohash_precision parameter is deprecated and will be removed in the next major release]
  32. // TEST[warning:geo_point geohash_prefix parameter is deprecated and will be removed in the next major release]
  33. The geohash cell can defined by all formats of `geo_points`. If such a cell is
  34. defined by a latitude and longitude pair the size of the cell needs to be
  35. setup. This can be done by the `precision` parameter of the filter. This
  36. parameter can be set to an integer value which sets the length of the geohash
  37. prefix. Instead of setting a geohash length directly it is also possible to
  38. define the precision as distance, in example `"precision": "50m"`. (See
  39. <<distance-units>>.)
  40. The `neighbor` option of the filter offers the possibility to filter cells
  41. next to the given cell.
  42. [source,js]
  43. --------------------------------------------------
  44. GET /_search
  45. {
  46. "query": {
  47. "bool" : {
  48. "must" : {
  49. "match_all" : {}
  50. },
  51. "filter" : {
  52. "geohash_cell": {
  53. "pin": {
  54. "lat": 13.4080,
  55. "lon": 52.5186
  56. },
  57. "precision": 3,
  58. "neighbors": true
  59. }
  60. }
  61. }
  62. }
  63. }
  64. --------------------------------------------------
  65. // CONSOLE
  66. // TEST[continued]
  67. [float]
  68. ==== Ignore Unmapped
  69. When set to `true` the `ignore_unmapped` option will ignore an unmapped field
  70. and will not match any documents for this query. This can be useful when
  71. querying multiple indexes which might have different mappings. When set to
  72. `false` (the default value) the query will throw an exception if the field
  73. is not mapped.