Use two versions of ES client API in single Java project

The Java project is already using 0.9 elastic client API for querying the old elastic indexes. Recently, we have added new indexes on 2.3.3 version and would like to query those using same Java API.
Is it possible to use 0.9 and 2.3.3 client ES Api within single Java API?

Hi,

Just to be sure: are the indices stored on a single cluster or two clusters in different versions?

Hey tanguy,

Yes they are stored on two different clusters in different versions (Even on two different servers).

I tested the REST client 5.0.0-alpha5 successfully with 1.x, 2.x and 5.0. I didn't try 0.90 though.
Might work but really unsure.

TransportClient won't work for sure.

0.90 is a very old version, I strongly advise you to upgrade your cluster.

I suppose you are using a TransportClient instance to connect to your remote cluster, right? If so, you have to know that TransportClient uses custom Java serialization and is only compatible with clusters with the same major version. You won't be able to use for example a version 2.3.3 client to connect to the old 0.90 cluster.

I think the easier and long-term solution would be to upgrade all clusters to the same version.

Other options could be to:

  • use a REST client
  • use shaded Jars
  • load the elasticsearch jars in different classloaders

All of these options involves heavy refactoring.

Maybe not relevant, but I tested the HTTP client back for reindex-from-remote against 0.90 and 0.20 as well and it works fine. It doesn't off a lot of high level stuff.

I think these four options are you options right now.