How to develop clients for several versions

Hi all,

Currently, I have a product that has a client for Elastic 2, using the Transport API.

Now, I want to develop another client for the Elastic server v 5.6 and on, and I would like to use the REST High Level Client, but I am not sure if this client (made with the 6.x jars) is going to support servers from both versions (5 and 6).

So, which is the best way to implement this scenario?
a) keep the current elastic 2.3.2 client because of backwards compatibility, and
b) add support to elastic 5 and elastic 6 (if possible, with one implementation)

I know you have the Low-Level REST Client, which would support all versions, but I would like to use the High Level one for the new implementation and keep the already-existing client for 2.3.2.

Another problem is with its dependencies, but I think I can solve it with the Shade plugin, shading all classes from this High Level Client (to let the current support for v2.3.2 as it is), to make a "uber-jar" with all its dependencies.

Thank you.

If you want to use a single client to query multiple versions during a rolling upgrade, you can as long as you use the high-level client in the lowest version. If you have 5.6 and 6.2, use the client for 5.6. Do keep in mind that anything that's new or removed in 6.x though is not going to work with such client. We do handle forward compatibility in the client, meaning that we are not strict when parsing responses back, we just ignore what we can't parse, which is good as it makes sure the client gives you back a response instead of throwing an error, bad because it doesn't know about future features/changes that impact the REST layer. This is ok for a rolling upgrade scenario, where you want a functional client while migrating, but once all nodes are on 6.2 you should migrate the client to 6.2 as well.

Some of this is explained in our docs: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-compatibility.html .

If the intention is to query multiple versions of Elasticsearch from the same application, I would recommend against the above approach, it will be problematic for the reasons outlined above.

Also, having transport client for 2.x and high-level client for 5.6 or 6.x in the same application will prove tricky in terms of dependencies.

Depending on how complicated your application is, I would consider using the low-level REST client, otherwise I would isolate the clients in separate applications that have each their own classpath, one per version.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.