# Java API or REST API for client development?

**URL:** <https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602>\
**Category:** Elasticsearch\
**Created:** [March 26, 2014, 9:46am UTC](https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602 "2014-03-26T09:46:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)\
**Post date:** [March 26, 2014, 9:46am UTC](https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602/1 "2014-03-26T09:46:16Z")

</div>

Hi,

We have a cloud management framework where all the event data are to be  
stored in elasticsearch. I have to start the client side code for this.

I need a suggestion here. Which one should I use, elasticsearch Java API or  
REST API for the client ?

Kindly suggest and mention the pros and cons for the same so it will be  
easy for me to decide the product design than latter hassel.

Subhadip

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a697bc63-cb55-4c9c-9a5e-2b315e443a0a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a697bc63-cb55-4c9c-9a5e-2b315e443a0a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Kevin\_Wang](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@Kevin\_Wang](https://discuss.elastic.co/u/Kevin_Wang)\
**Post date:** [March 26, 2014, 10:26am UTC](https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602/2 "2014-03-26T10:26:54Z")

</div>

There is no official REST client for Java, so I think if your app is in  
Java you have to use Java API. If not in Java you have to use REST API

On Wednesday, March 26, 2014 8:46:16 PM UTC+11, Subhadip Bagui wrote:

> Hi,
> 
> We have a cloud management framework where all the event data are to be  
> stored in elasticsearch. I have to start the client side code for this.
> 
> I need a suggestion here. Which one should I use, elasticsearch Java API  
> or REST API for the client ?
> 
> Kindly suggest and mention the pros and cons for the same so it will be  
> easy for me to decide the product design than latter hassel.
> 
> Subhadip

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1a863a31-ac80-4cc8-bf0a-c0f6ecb6771d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1a863a31-ac80-4cc8-bf0a-c0f6ecb6771d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)\
**Post date:** [March 26, 2014, 10:42am UTC](https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602/3 "2014-03-26T10:42:19Z")

</div>

My app is in Java only. So what I mean is should I use elasticsearch Java  
client or available REST api's only using HttpClient and all.

What will be more flexiable for multiplatform ingration ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2cd7714f-ff38-44a5-a5c2-fdde329c9874%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2cd7714f-ff38-44a5-a5c2-fdde329c9874%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Kevin\_Wang](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@Kevin\_Wang](https://discuss.elastic.co/u/Kevin_Wang)\
**Post date:** [March 26, 2014, 10:50am UTC](https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602/4 "2014-03-26T10:50:17Z")

</div>

I think it's better to use official client. REST API will also call Java  
API internally. so if you use REST it will be Java -\> REST -\> Java.  
What do you mean by multiplatform? Android? I'm not quite sure ES Java API  
works on Android or not, but I think the Android shouldn't talk to ES  
directly.

Regards,  
Kevin

On Wednesday, March 26, 2014 9:42:19 PM UTC+11, Subhadip Bagui wrote:

> My app is in Java only. So what I mean is should I use elasticsearch Java  
> client or available REST api's only using HttpClient and all.
> 
> What will be more flexiable for multiplatform ingration ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/bbe9688c-ef1f-46e3-9ecd-9d183672e310%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bbe9688c-ef1f-46e3-9ecd-9d183672e310%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![maf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maf/32/77965_2.png) [@maf](https://discuss.elastic.co/u/maf)\
**Post date:** [March 26, 2014, 11:45am UTC](https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602/5 "2014-03-26T11:45:19Z")

</div>

The Java API is said to have better performance (and I believe that). The  
drawbacks are that you must use the exact same version of the java API  
library on the client as the server runs, as well as the same version of  
Java. So upgrades suck.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4a130362-4732-423b-8994-937e2662c38a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4a130362-4732-423b-8994-937e2662c38a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Graham\_Tackley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/graham_tackley/32/1697_2.png) [@Graham\_Tackley](https://discuss.elastic.co/u/Graham_Tackley)\
**Post date:** [March 26, 2014, 12:12pm UTC](https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602/6 "2014-03-26T12:12:56Z")

</div>

Not true anymore: the java client has been compatible between minor  
versions since 0.90 as far as I remember. 1.0.0 client is currently working  
just fine against my 1.0.1 cluster, and my experimentation today shows that  
it also works fine against 1.1.0. So this used to be a nightmare requiring  
synchronised upgrades, but hasn't been for a while.

FWIW we use the java client (in transport client mode) extensively from our  
scala apps, and it works brilliantly. I'd definitely recommend.

On Wednesday, 26 March 2014 11:45:19 UTC, Martin Forssen wrote:

> The Java API is said to have better performance (and I believe that). The  
> drawbacks are that you must use the exact same version of the java API  
> library on the client as the server runs, as well as the same version of  
> Java. So upgrades suck.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/610cb839-1625-43d6-be57-db654de9aace%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/610cb839-1625-43d6-be57-db654de9aace%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [March 26, 2014, 6:40pm UTC](https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602/7 "2014-03-26T18:40:44Z")

</div>

Using same version on all nodes of a cluster still holds. Otherwise you  
will get unpredictable behavior, especially in case of using new features.

Jörg

On Wed, Mar 26, 2014 at 1:12 PM, Graham Tackley [graham@tackley.net](mailto:graham@tackley.net) wrote:

> Not true anymore: the java client has been compatible between minor  
> versions since 0.90 as far as I remember. 1.0.0 client is currently working  
> just fine against my 1.0.1 cluster, and my experimentation today shows that  
> it also works fine against 1.1.0. So this used to be a nightmare requiring  
> synchronised upgrades, but hasn't been for a while.
> 
> FWIW we use the java client (in transport client mode) extensively from  
> our scala apps, and it works brilliantly. I'd definitely recommend.
> 
> On Wednesday, 26 March 2014 11:45:19 UTC, Martin Forssen wrote:
> 
> > The Java API is said to have better performance (and I believe that). The  
> > drawbacks are that you must use the exact same version of the java API  
> > library on the client as the server runs, as well as the same version of  
> > Java. So upgrades suck.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/610cb839-1625-43d6-be57-db654de9aace%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/610cb839-1625-43d6-be57-db654de9aace%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/610cb839-1625-43d6-be57-db654de9aace%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/610cb839-1625-43d6-be57-db654de9aace%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFdbKjEH0u5EBKUZHrSNnkPUESHYkW7RiZkw5epOG20qg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFdbKjEH0u5EBKUZHrSNnkPUESHYkW7RiZkw5epOG20qg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Andrew\_Mehler](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@Andrew\_Mehler](https://discuss.elastic.co/u/Andrew_Mehler)\
**Post date:** [August 21, 2014, 4:34pm UTC](https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602/8 "2014-08-21T16:34:06Z")

</div>

I believe this is true again. Aggregations API recently changed, and code  
no longer compiles. The REST apis definitely change at a slower rate.

On Wednesday, March 26, 2014 8:12:56 AM UTC-4, Graham Tackley wrote:

> Not true anymore: the java client has been compatible between minor  
> versions since 0.90 as far as I remember. 1.0.0 client is currently working  
> just fine against my 1.0.1 cluster, and my experimentation today shows that  
> it also works fine against 1.1.0. So this used to be a nightmare requiring  
> synchronised upgrades, but hasn't been for a while.
> 
> FWIW we use the java client (in transport client mode) extensively from  
> our scala apps, and it works brilliantly. I'd definitely recommend.
> 
> On Wednesday, 26 March 2014 11:45:19 UTC, Martin Forssen wrote:
> 
> > The Java API is said to have better performance (and I believe that). The  
> > drawbacks are that you must use the exact same version of the java API  
> > library on the client as the server runs, as well as the same version of  
> > Java. So upgrades suck.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/56137938-e3d8-456a-99b3-42465dcb6068%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/56137938-e3d8-456a-99b3-42465dcb6068%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Jilles\_van\_Gurp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jilles_van_gurp/32/879_2.png) [@Jilles\_van\_Gurp](https://discuss.elastic.co/u/Jilles_van_Gurp)\
**Post date:** [August 26, 2014, 2:57pm UTC](https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602/9 "2014-08-26T14:57:14Z")

</div>

I use a in house developed java rest client for elasticsearch.  
Unfortunately it's not in any shape to untangle from our code base and put  
on Github yet but I might consider that if there's more interest.

Basically I use apache httpclient, I implemented a simple round robin  
strategy so I can failover if nodes go down, and I implemented a simple  
rest client around this to support put/post/delete/get requests. Also added  
some basic interpretation of statuses and have mapped those to sensible  
exceptions.

The idea is that this client is wrapped with another client that supports  
more high level APIs that are exposed from elasticsearch. So you can do  
things like index/delete documents, manage aliases, do bulk indexing etc.  
My long term goal was actually to have two implementations of that client  
one for REST and one for embedded elasticsearch. That would be an  
interesting project because it would give you choice. Except, I never got  
around to doing the embedded client implementation since we don't really  
need it so far. Something else that we use is to model the query DSL using  
static java methods and provides a simple DSL for creating queries in Java.  
This in turn uses my github jsonj project that allows you to  
programmatically manipulate json structures.

None of this is particularly complicated but altogether there is quite a  
bit of code to write and quite a few things you can get wrong. It's always  
hard to separate the general purpose stuff from the application specific  
stuff and thats one reason why I have not yet put this code out.

Jilles

On Wednesday, March 26, 2014 10:46:16 AM UTC+1, Subhadip Bagui wrote:

> Hi,
> 
> We have a cloud management framework where all the event data are to be  
> stored in elasticsearch. I have to start the client side code for this.
> 
> I need a suggestion here. Which one should I use, elasticsearch Java API  
> or REST API for the client ?
> 
> Kindly suggest and mention the pros and cons for the same so it will be  
> easy for me to decide the product design than latter hassel.
> 
> Subhadip

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/350caf92-63c1-4a0c-a1b5-781cb4b09cfb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/350caf92-63c1-4a0c-a1b5-781cb4b09cfb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:06am UTC](https://discuss.elastic.co/t/java-api-or-rest-api-for-client-development/16602/10 "2017-07-06T01:06:19Z")

</div>


