go-elasticsearch icon indicating copy to clipboard operation
go-elasticsearch copied to clipboard

esdsl/SortCombinations not available in 8.18, only in 9.0

Open agnivade opened this issue 6 months ago • 4 comments

This PR (https://github.com/elastic/go-elasticsearch/pull/968) changes the sort API to use SortCombinations, but it's difficult to use the API without having the file (typedapi/esdsl/sortcombinations.go) which was added in 9.0 (https://github.com/elastic/go-elasticsearch/pull/995). To make it work, I've had to copy the file locally.

I am not sure if this was intentional or not. But it certainly makes like difficult to make such breaking changes in minor versions.

agnivade avatar May 13 '25 09:05 agnivade

I'm struggling with the same issue - the upgrade go-elasticsearch from 8.17 to 8.18 breaks my code.

I use typed api and Sort method now accepts (sorts ...types.SortCombinationsVariant). I cloned this repo (because github denied to show whole typedapi/types directory due to limitation to 1000 files in directory) and I tried to find what type should I use for sorting. And unless I'm mistaken, there is no type that implements this interface in 8.18 codebase.

ISim avatar May 27 '25 11:05 ISim

Came to the same conclusion as @ISim while debugging what turned out to be this issue. The 8.18 release makes the .Sort method of the typed API client unusable. It specifies an interface that is not implemented anywhere and thus especially not backwards-compatible with SortOptions.

For my service I downgraded to v8.17.1, which is not affected. Can't upgrade to v9 yet either because that would require the server to be at version 9.

mologie avatar Jun 01 '25 10:06 mologie

Oh that's interesting! I was going to open another issue about similar problems, but as we've only just started checking this package out we were only looking at 8.18 and above... So those -Variant interfaces are a new addition? Anyway, relieved to see I'm not the only one unsure about why the code was structured that way, given nothing (other than the wrappers defined in esdsl) implements the required interfaces.

The issue is in fact worse than just from a usability point: since there are several union types represented as simple any, there aren't any compile-time safety checks, and it doesn't look like there are runtime ones either, and thus there are uncaught bugs in esdsl: e.g. sortcombinations.go#L43, a pointer to the -Variant interface gets assigned to a variable that is meant to be the SortCombinations itself...

Curious to see what the plan will be moving ahead!

itizir avatar Jun 03 '25 10:06 itizir

Hi everyone,

First of all, sorry for the delay. The current 8.18.0 version of the client is broken. We are currently working on a fix which we hope to release next week.

Please use the 8.17.1 version for the time being.

Anaethelion avatar Jun 12 '25 15:06 Anaethelion

Hi all,

I believe this issue was fixed in #1015 , please let me know if issues still persist

MattDevy avatar Nov 25 '25 14:11 MattDevy