Thanks for update.
I have used geo_shape since it supports for multipolygon.
I have tried with below query to get coordinates under 2 different polygon and its working.
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" :
{
"geo_shape": {
"_name": "named_query",
"boost": 1.1,
"ignore_unmapped": true,
"location": {
"relation": "intersects",
"shape": {
"type": "multipolygon",
"coordinates": [
[ [[2,3],[2,6],[5,7],[5,4],[2,3]] ],
[ [[-2,3],[-2,6],[-5,7],[-5,4],[-2,3]] ] ]
]
}
}
}
}
}
}
}
And have one more query - with data type geo_shape, get the common coordinates between 3 polygon
E.g : I have attached the diagram to understand the same and used a below query. Even though used relation as intersects in GET I got all the coordinates under all polygon. Now how we filter out common coordinates under ( (polygon1 and polygon2) or (polygon2 and polygon3) ) i.e need to get the 3,3and -3,4 coordinates only?
Schema:
"location": {
"type": "geo_shape"
},
Created below data in DB: (created multiple coordinates under polygon)
Polygon 3:
"location": {
"type": "point",
"coordinates": [3,3]
},
"location": {
"type": "point",
"coordinates": [5,3]
},
Polygon 1:
"location": {
"type": "point",
"coordinates": [-3,4]
},
"location": {
"type": "point",
"coordinates": [-5,4]
}
GET query:
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" :
{
"geo_shape": {
"_name": "named_query",
"boost": 1.1,
"ignore_unmapped": true,
"location": {
"relation": "intersects",
"shape": {
"type": "multipolygon",
"coordinates": [
[ [[2,3],[2,6],[5,7],[5,4],[2,3]] ], - polygon3
[ [[-2,3],[-2,6],[-5,7],[-5,4],[-2,3]] ] – polygon1
[[-3.5,2],[-3.5,7],[3.5,7],[3.5,2],[-3.5,2]] – polygon2
]
}
}
}
}
}
}
}