# Use two versions of ES client API in single Java project

**URL:** <https://discuss.elastic.co/t/use-two-versions-of-es-client-api-in-single-java-project/57760>\
**Category:** Elasticsearch\
**Created:** [August 11, 2016, 6:18am UTC](https://discuss.elastic.co/t/use-two-versions-of-es-client-api-in-single-java-project/57760 "2016-08-11T06:18:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prakhar\_Chhipa](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@Prakhar\_Chhipa](https://discuss.elastic.co/u/Prakhar_Chhipa)\
**Post date:** [August 11, 2016, 6:18am UTC](https://discuss.elastic.co/t/use-two-versions-of-es-client-api-in-single-java-project/57760/1 "2016-08-11T06:18:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tanguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy/32/6030_2.png) [@tanguy](https://discuss.elastic.co/u/tanguy)\
**Post date:** [August 11, 2016, 7:43am UTC](https://discuss.elastic.co/t/use-two-versions-of-es-client-api-in-single-java-project/57760/2 "2016-08-11T07:43:55Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![Prakhar\_Chhipa](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@Prakhar\_Chhipa](https://discuss.elastic.co/u/Prakhar_Chhipa)\
**Post date:** [August 11, 2016, 7:58am UTC](https://discuss.elastic.co/t/use-two-versions-of-es-client-api-in-single-java-project/57760/3 "2016-08-11T07:58:24Z")

</div>

Hey tanguy,

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 11, 2016, 8:06am UTC](https://discuss.elastic.co/t/use-two-versions-of-es-client-api-in-single-java-project/57760/4 "2016-08-11T08:06:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tanguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy/32/6030_2.png) [@tanguy](https://discuss.elastic.co/u/tanguy)\
**Post date:** [August 11, 2016, 9:47am UTC](https://discuss.elastic.co/t/use-two-versions-of-es-client-api-in-single-java-project/57760/5 "2016-08-11T09:47:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [August 11, 2016, 1:42pm UTC](https://discuss.elastic.co/t/use-two-versions-of-es-client-api-in-single-java-project/57760/6 "2016-08-11T13:42:58Z")

</div>

> [@dadoonet](#):
>
> 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.

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.

> [@tanguy](#):
>
> 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

I think these four options are you options right now.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:28pm UTC](https://discuss.elastic.co/t/use-two-versions-of-es-client-api-in-single-java-project/57760/7 "2017-07-05T22:28:21Z")

</div>


