elastic / elasticsearch-java

Official Elasticsearch Java Client
Apache License 2.0
397 stars 228 forks source link

Support for geo distance sort on nested fields #831

Closed cmbarbu closed 1 week ago

cmbarbu commented 1 month ago

Description

Nested sort seems to be available only for co.elastic.clients.elasticsearch._types.FieldSort, but not for co.elastic.clients.elasticsearch._types.GeoDistanceSort. Consequently, trying to sort by distance on a nested field yields an error:

"query_shard_exception","reason":"it is mandatory to set the [nested] context on the nested sort field: [geoLocation.geoPoint].

This used to be possible in 7.x. Are there any plans to support this again in 8.x?

l-trotta commented 1 month ago

Hello, thanks for reporting this! Seems like we're missing the option in GeoDistanceSort, it's a problem with the API specification used to produce the Java code, we'll fix it and regenerate the client to solve the issue.

cmbarbu commented 3 weeks ago

Indeed, it seems the class GeoDistanceSort is missing the nested property:

https://github.com/elastic/elasticsearch-specification/blob/main/specification/_types/sort.ts#L58-L66

Would it help if I opened a ticket in that repo as well?