I have a document with areas property. This property is an array of polygons. Let's say polygons represent the boundaries of some cities.
Given that I have a bounding box I want to query for those documents that have at least one of the polygons WITHIN the bounding box.
My query works if there is a single area matching the filter or the bounding box is so large all of the polygons are within it.
{
"query":{
"bool":{
"filter":[
{
"geo_shape":{
"areas":{
"shape":{
"type":"envelope",
"coordinates":[
[
20.9325116,
52.2280665
],
[
21.0069884,
52.1928718
]
]
},
"relation":"within"
}
}
}
]
}
}
}
A sample areas property looks like this:
{
"areas":[
{
"type":"polygon",
"coordinates":[
]
},
{
"type":"polygon",
"coordinates":[
]
}
]
}