mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 04:58:50 +00:00
c595322d90
The change adds a new option to the geo_* queries: ignore_unmapped. If this option is set to false, the toQuery method on the QueryBuilder will throw an exception if the field specified in the query is unmapped. If the option is set to true, the toQuery method on the QueryBuilder will return a MatchNoDocsQuery. The default value is false so the queries work how they do today (throwing an exception on unmapped field)
72 lines
2.3 KiB
Plaintext
72 lines
2.3 KiB
Plaintext
[[query-dsl-geohash-cell-query]]
|
|
=== Geohash Cell Query
|
|
|
|
The `geohash_cell` query provides access to a hierarchy of geohashes.
|
|
By defining a geohash cell, only <<geo-point,geopoints>>
|
|
within this cell will match this filter.
|
|
|
|
To get this filter work all prefixes of a geohash need to be indexed. In
|
|
example a geohash `u30` needs to be decomposed into three terms: `u30`,
|
|
`u3` and `u`. This decomposition must be enabled in the mapping of the
|
|
<<geo-point,geopoint>> field that's going to be filtered by
|
|
setting the `geohash_prefix` option:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
{
|
|
"mappings" : {
|
|
"location": {
|
|
"properties": {
|
|
"pin": {
|
|
"type": "geo_point",
|
|
"geohash": true,
|
|
"geohash_prefix": true,
|
|
"geohash_precision": 10
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
--------------------------------------------------
|
|
|
|
The geohash cell can defined by all formats of `geo_points`. If such a cell is
|
|
defined by a latitude and longitude pair the size of the cell needs to be
|
|
setup. This can be done by the `precision` parameter of the filter. This
|
|
parameter can be set to an integer value which sets the length of the geohash
|
|
prefix. Instead of setting a geohash length directly it is also possible to
|
|
define the precision as distance, in example `"precision": "50m"`. (See
|
|
<<distance-units>>.)
|
|
|
|
The `neighbor` option of the filter offers the possibility to filter cells
|
|
next to the given cell.
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
{
|
|
"bool" : {
|
|
"must" : {
|
|
"match_all" : {}
|
|
},
|
|
"filter" : {
|
|
"geohash_cell": {
|
|
"pin": {
|
|
"lat": 13.4080,
|
|
"lon": 52.5186
|
|
},
|
|
"precision": 3,
|
|
"neighbors": true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
--------------------------------------------------
|
|
|
|
[float]
|
|
==== Ignore Unmapped
|
|
|
|
When set to `true` the `ignore_unmapped` option will ignore an unmapped field
|
|
and will not match any documents for this query. This can be useful when
|
|
querying multiple indexes which might have different mappings. When set to
|
|
`false` (the default value) the query will throw an exception if the field
|
|
is not mapped.
|