Hi!
We have a geo shape field which we store multi polygons and we want to filter it with a coordinate.
Desired search request is:
"geo_shape": {
"area": {
"shape": {
"type": "point",
"coordinates": [
29.0,
40.0
]
},
"relation": "intersects"
}
}
But with elastic java client v8.6.0 I couldn't find a way to build this query. What I've done so far is:
new GeoShapeQuery.Builder()
.shape(new GeoShapeFieldQuery.Builder()
.shape(JsonData.of(new GeoLocation.Builder()
.coords(List.of(
request.getLatitude(),
request.getLongitude())).build()))
.build())
.field(AREA).build()._toQuery()
And with this I got the following:
"geo_shape": {
"area": {
"shape": [
29.147841,
40.91953
]
}
}
It doesn't work because Elasticsearch expects type
and coordinates
fields.
What is the correct way to achieve this?
Thanks!