-
Aivaras Gotovskis authoredAivaras Gotovskis authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
GeoShape.md 1.71 KiB
Geo Shape Filter
More info about geo shape filter is in the official elasticsearch docs
Filter documents indexed using the geo shape type.
Simple example
{
"query":{
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_shape": {
"location": {
"shape": {
"type": "envelope",
"coordinates" : [[13.0, 53.0], [14.0, 52.0]]
}
}
}
}
}
}
}
And now the query via DSL:
$geoShapeFilter = new GeoShapeFilter();
$geoShapeFilter->addShape('location', 'envelope', [[13.0, 53.0], [14.0, 52.0]]);
$search = new Search();
$search->addFilter($geoShapeFilter);
$queryArray = $search->toArray();
Pre Indexed Shape
{
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_shape": {
"location": {
"indexed_shape": {
"id": "DEU",
"type": "countries",
"index": "shapes",
"path": "location"
}
}
}
}
}
}
And now the query via DSL:
$geoShapeFilter = new GeoShapeFilter();
$geoShapeFilter->addPreIndexedShape(
'location',
'DEU',
'countries',
'shapes',
'location'
);
$search = new Search();
$search->addFilter($geoShapeFilter);
$queryArray = $search->toArray();