geohash-cell-query.asciidoc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. {
  14. "mappings" : {
  15. "location": {
  16. "properties": {
  17. "pin": {
  18. "type": "geo_point",
  19. "geohash": true,
  20. "geohash_prefix": true,
  21. "geohash_precision": 10
  22. }
  23. }
  24. }
  25. }
  26. }
  27. --------------------------------------------------
  28. The geohash cell can defined by all formats of `geo_points`. If such a cell is
  29. defined by a latitude and longitude pair the size of the cell needs to be
  30. setup. This can be done by the `precision` parameter of the filter. This
  31. parameter can be set to an integer value which sets the length of the geohash
  32. prefix. Instead of setting a geohash length directly it is also possible to
  33. define the precision as distance, in example `"precision": "50m"`. (See
  34. <<distance-units>>.)
  35. The `neighbor` option of the filter offers the possibility to filter cells
  36. next to the given cell.
  37. [source,js]
  38. --------------------------------------------------
  39. {
  40. "bool" : {
  41. "must" : {
  42. "match_all" : {}
  43. },
  44. "filter" : {
  45. "geohash_cell": {
  46. "pin": {
  47. "lat": 13.4080,
  48. "lon": 52.5186
  49. },
  50. "precision": 3,
  51. "neighbors": true
  52. }
  53. }
  54. }
  55. }
  56. --------------------------------------------------
  57. [float]
  58. ==== Ignore Unmapped
  59. When set to `true` the `ignore_unmapped` option will ignore an unmapped field
  60. and will not match any documents for this query. This can be useful when
  61. querying multiple indexes which might have different mappings. When set to
  62. `false` (the default value) the query will throw an exception if the field
  63. is not mapped.