Can a Java program operate on multiple versions of elasticsearch?

I need to develop an es automation tool.
Our company's es cluster has multiple versions.
I found that many clients require the corresponding ES version.
Currently I can only think of Java indirectly using the curl and http tools to operate the ES.
Such as "curl -XGET http://localhost:9200/_snapshot/test_backup/_all?pretty".
Automated tools designed in this way can operate all versions of ES.

I hope some experts can help me and provide some suggestions. Thank you.

Hi @sanjun1995,

I don't use Java but Python and we have a similar case, so maybe my solution can also apply to your case. In my company we have different version of elastic [2, 5, 6] and for that we installed the different versions of the elastic library making call for the specific connection with the related elastic lib.
The syntax in library don't change so much between version so it will have a small impact on your code.

Thanks for your advice.
In this case, does the call need to bring specific version information?
I hope this is transparent.

Do you choose different libraries to call based on the version information of the cluster?

As I understand my case is different as I already know the endpoint and the version so I don't need to guess. For example 172.16.10.x is version 2.x and it will not change, at least this year.
If you don't know which version is running as far as I know the GET always return the version of elastic. This one didn't change from version 0.x You can get it from here and load the correct lib version.
In python you can prefix your import and install in different directory so it make very easy to have different versions of a library. For Java it's maybe more hard.

Wow, your idea is very good, I am afraid that multiple libraries in Java will cause dependency conflicts.

in python there's virtual environment that make think more easy to use.

Thank you for your help :revolving_hearts:

1 Like

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