Geo-shape query within

by this document (https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html#_spatial_relations), I made query like this,

"filter":{
"geo_shape":{
"boundaries":{
"shape": {
"type": "envelope",
"coordinates" : [[126.9243621826172, 37.580228767905275],[127.10941314697267, 37.44406286652748]]
},
"relation": "within"
}
}
},

but there is 2 problems.

< 1 >
The within filter gets only the regions that are entirely contained within.
I would also like to bring an area that contains only a few parts of the current map.

< 2 >
I think it's the same problem as above. If the envelop coordinates of the map do not contain a region, elasticsearch does not return the region.

How can I handle this? Is it possible to use multiple condition within and contains?

Not sure if I understand your questions:

What do you mean with few parts? Either you just need an intersect query or you are referring to shapes that are composed of multiple components (e.g multi-polygons) and you just want to match if at least one of those components is within.

Could you clarify?

Using "INTERSECTS" instead of "within" solved all the problems. Sorry for the ambiguous english.

No problem! In addition INTERSECTS is the best performing query so good it is enough :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.