Skip to content
Snippets Groups Projects
Commit 24f307e5 authored by Mantas Marcinkevičius's avatar Mantas Marcinkevičius Committed by Simonas Šerlinskas
Browse files

added documentation for geo polygon query (#219)

parent d88c2e19
No related branches found
No related tags found
No related merge requests found
Documentation in progress...
\ No newline at end of file
# Geo Polygon Query
> More info about geo polygon query is in the [official elasticsearch docs][1]
A query allowing to include hits that only fall within a polygon of points. Here is an example:
## Simple example
```JSON
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_polygon" : {
"person.location" : {
"points" : [
{"lat" : 40, "lon" : -70},
{"lat" : 30, "lon" : -80},
{"lat" : 20, "lon" : -90}
]
}
}
}
}
}
}
```
In DSL:
```php
$points = [
['lat' => 40, 'lon' => -70],
['lat' => 30, 'lon' => -80],
['lat' => 20, 'lon' => -90],
];
$search = new Search();
$boolQuery = new BoolQuery();
$boolQuery->add(new MatchAllQuery());
$geoQuery = new GeoPolygonQuery('person.location', $points);
$boolQuery->add($geoQuery, BoolQuery::FILTER);
$search->addQuery($boolQuery);
$queryArray = $search->toArray();
```
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment