Trying out ES 9 — any Java API changes?

When upgrading from Elasticsearch 8 to 9, do I need to update my application server Java code? I use the ES 8 Java API to talk to an ES 8 (and 9?) server.

Is there any ES Java client version 9, for talking with ES server version 9? With some (breaking?) API changes? Or can I just continue using the ES 8 client, no changes required, except for upgrading to an ES 9 server? (With "client" here being my application server.)

In the ES 9.0.0-RC announcement: [ANNOUNCEMENT] - Elastic 9.0.0-RC1 is available, a Docker image is mentioned — that means I'd start using an ES 9 server. But there's nothing about any ES 9 client, or 8 —> 9 API changes. No version 9 over at the ES docs website: Elasticsearch Guide [8.17] | Elastic (as of April 5 2025).

Nice with a new version of ES anyway :- ) Looking forward to upgrading

There will be, but it might follow some time after the server release. However ...

... certainly as an interim measure this is what we expect folks to do. Elasticsearch has a REST compatibility mode which keeps the 8.x response format even in 9.x clusters to keep clients working across the upgrade.

1 Like

Ok that sounds great :- ) Then I'll experiment with upgrading only the server, and see what'll happen.

(To use the REST compatibility mode, apparently I need to add:

Accept: "application/vnd.elasticsearch+json;compatible-with=8"
Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"

(from the docs you linked, and 8 instead of 7))

AIUI the Java client adds these headers automatically, you don't need to take any action to enable this compatibility mode when working with a v9 cluster.

Just want to make sure I'm clear.
I can still use REST api in compatibility mode when running ES9.x, right?
I could just use latest REST client 8.18.x java code on ES 9.x in compatibility mode.

Yes, as long as you don't need to use any new features.

1 Like

I just realized that "elasticsearch-rest-high-level-client" is only supported to 7.17.28.
Does this mean that I should use that version on ES version 9?

That would be skipping a major version though.

No, I wouldn't expect a 7.x client to work well against a 9.x cluster. The compatibility mode only gives one major version of leeway. You need to upgrade your client to an 8.x version (as you suggested in your previous message) before upgrading the cluster to 9.x.

But rest-high-level-client maven doesn't support 8.x though.
That's my question/confusion.

Are these 2 repo sort of equivalent?

        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-client</artifactId>
        <version>8.x.x</version>

        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>7.17.28</version>      <--- 7.17.28 is the latest supported version

I attempted to just switch to the new package "elasticsearch-rest-client" but got bunch of errors (lots of changes between the 2); therefore, I assume it's not meant for what I was doing.

Right yes the elasticsearch-rest-high-level-client was deprecated in 7.x and is no longer maintained. It's replaced with the newer elasticsearch-rest-client library in newer versions, to which you need to migrate. It is not a simple drop-in replacement library, you will need to update the calling code.

Wait, sorry, correction: I'm not sure what elasticsearch-rest-client is but I don't think you should be using that. I meant co.elastic.clients:elasticsearch-java, see e.g. Maven.

hmmm. I thought that is for the new java-api client, no?

Let me clarify what we are running today. Maybe that will help describing what I'm trying to figure out.

Today, we are running ES 8.10.2.
In maven, We are using:

    <groupId>org.elasticsearch.client</groupId>
    <artifactId>elasticsearch-rest-high-level-client</artifactId>
    <version>7.17.28</version>      

We are already using 1 major release older rest high client on 8.10.2 database.

We have not been able to migrate all the code to the java-api client yet (mainly due to the lack of example code we can find, so the transition is painfully slow. There are many threads regarding documentations. I won't elaborate here).

Is it possible to continue to use REST calls in our java code on new ES 9.x?

If yes, what maven version would be recommended?
(*note: I would/should not expect much code changes since it'll still be the standard REST. So if I see lots of compilation errors when switching to the new maven, I suspect something's not right, etc.)

Hope this clarifies my question more.
Thanks.

This maven is what I was referring to in my previous post:

    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-client</artifactId>
        <version>9.0.1</version>
    </dependency>

Some APIs haven't changed between 7.x and 9.x so those will work with older clients. But others won't. So yes kinda partly possible but definitely not advisable.

The only path I can recommend is to finish this migration before you start to think about upgrading to ES 9.x. There is no massive rush to adopt 9.x yet, the 8.x series will continue to be maintained until January 2027. On the other hand the 7.x client is now unmaintained so will see no more bug fixes or security updates, so it's rather urgent to stop using it ASAP.

Probably 8.10.2 since that's the server version you're using. The Java client is quite broadly compatible, both forwards and backwards, so it doesn't matter hugely, but you may as well match versions for now until the migration is complete.

Thanks for the info.
But I continue to get conflicting info. Below clearly specifies that java rest high client only supports up to 7.17.

Maybe it's the low rest client is still being supported? That means I have to translate/map the query myself into the low level http rest payload?

Nono it's the one I pointed you to here:

This one has 7.x and 8.x and 9.x versions.

I understand that. But it's for java-api client & lower level REST call.
Not REST-HIGH-CLIENT.

It requires major code change to use that package from where I am today...

Yes that's unfortunately true. That's why we left more than 3 years in between announcing that the high-level client is deprecated (in 7.16.0, so 2021-12-07) and the end of its supported life (2025-05-25).

1 Like