I need to build a query on a database with around 50k terrain polygons (stored as geo_shape polygons on ES) where I give a point and it returns every polygon that contains this point.
I tried to create it, but getting incorrect result.
// Code
- Create Index
{
"mappings": {
"TYPE_NAME": {
"properties": {
"location": {
"type": "geo_shape"
}
}
}
}
}
- Insert document:
{
"location": {
"type": "polygon",
"coordinates": [
[
[
88.357934264,
22.55818208
],
[
88.365144042,
22.556745416
],
[
88.363384513,
22.551920096
],
[
88.360412625,
22.552474967
],
[
88.360788135,
22.553614427
],
[
88.35667899,
22.55359461
],
[
88.357934264,
22.55818208
]
]
]
}
}
- Search for all polygons that contain the point:
{
"query": {
"geo_shape": {
"location": {
"shape": {
"type": "point",
"coordinates": [88.360, 22.555]
},
"relation": "within"
}
}
}
}
Result:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
Please let me know if I am missing out something as it is returning WRONG result.