We are using ElasticsearchClient instance to build our query and communicate with elasticsearch hosted on elastic-cloud version 8.5.3.
We could not find any information on how to inject nested path while creating GeoDistanceSort object.
Sort query that we are trying to convert to using Java:
"sort":[
{
"_geo_distance":{
"nested":{
"path":"facility"
},
"facility.location":{
"lat":25.240995,
"lon":55.751156
},
"unit":"km",
"order":"asc",
"mode" : "min",
"distance_type" : "arc",
"ignore_unmapped": true
}
}
]
Maven dependency:
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>8.5.3</version>
</dependency>
We have referred to the following official elastic documentation for JavaClient 8.5.3: