# Get Elasticsearch Version with Java Api

**URL:** <https://discuss.elastic.co/t/get-elasticsearch-version-with-java-api/14599>\
**Category:** Elasticsearch\
**Created:** [November 26, 2013, 2:03pm UTC](https://discuss.elastic.co/t/get-elasticsearch-version-with-java-api/14599 "2013-11-26T14:03:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_Meiwald](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Stefan\_Meiwald](https://discuss.elastic.co/u/Stefan_Meiwald)\
**Post date:** [November 26, 2013, 2:03pm UTC](https://discuss.elastic.co/t/get-elasticsearch-version-with-java-api/14599/1 "2013-11-26T14:03:31Z")

</div>

I am looking for the Java API pendant to

curl -XGET [http://localhost:9200](http://localhost:9200)

With a Result like:

```
{
 "ok" : true, 
  "status" : 200,
 "name" : "Kierrok",
 "version" : {
   "number" : "0.90.7",
   "build_hash" : "36897d07dadcb70886db7f149e645ed3d44eb5f2",
   "build_timestamp" : "2013-11-13T12:06:54Z",
   "build_snapshot" : false,
   "lucene_version" : "4.5.1"
 },
 "tagline" : "You Know, for Search"

```

}

Actually its only about the version. I want to write a test which ensures  
that I am using a version \>= 0.90.5

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [November 26, 2013, 2:36pm UTC](https://discuss.elastic.co/t/get-elasticsearch-version-with-java-api/14599/2 "2013-11-26T14:36:18Z")

</div>

Have a look at Nodes Info: [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-nodes-info.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-nodes-info.html)  
curl -XGET '[http://localhost:9200/\_cluster/nodes?pretty](http://localhost:9200/_cluster/nodes?pretty)'  
{  
"ok" : true,  
"cluster\_name" : "elasticsearch",  
"nodes" : {  
"U2Kxuc4BQuefH9bz6q8glA" : {  
"name" : "Captain Atlas",  
"transport\_address" : "inet[/192.168.0.15:9300]",  
"hostname" : "MacBook-Air-de-David.local",  
"version" : "0.90.7",  
"http\_address" : "inet[/192.168.0.15:9200]"  
}  
}  
}

HTH

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 26 novembre 2013 at 15:03:35, Stefan Meiwald ([st.meiwald@gmail.com](mailto:st.meiwald@gmail.com)) a écrit:

I am looking for the Java API pendant to

curl -XGET [http://localhost:9200](http://localhost:9200)

With a Result like:

```
{
 "ok" : true,
  "status" : 200,
 "name" : "Kierrok",
 "version" : {
   "number" : "0.90.7",
   "build_hash" : "36897d07dadcb70886db7f149e645ed3d44eb5f2",
   "build_timestamp" : "2013-11-13T12:06:54Z",
   "build_snapshot" : false,
   "lucene_version" : "4.5.1"
 },
 "tagline" : "You Know, for Search"

```

}

## Actually its only about the version. I want to write a test which ensures that I am using a version \>= 0.90.5

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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Stefan\_Meiwald](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Stefan\_Meiwald](https://discuss.elastic.co/u/Stefan_Meiwald)\
**Post date:** [November 26, 2013, 3:06pm UTC](https://discuss.elastic.co/t/get-elasticsearch-version-with-java-api/14599/3 "2013-11-26T15:06:09Z")

</div>

Thank you very much. Here is my implementation(I am using Scala). Just in  
case anyone else is doing the same.

case class GetEsVersionQuery(esClient: Client) {  
lazy val p = promiseNodesInfoResponse

esClient  
.admin()  
.cluster()  
.prepareNodesInfo()  
.all()  
.execute()  
.addListener(new ActionListener[NodesInfoResponse] {

```
def onFailure(e: Throwable) = {
  p failure e
}

def onResponse(response: NodesInfoResponse) = p success response

```

})

def execute: Future[NodesInfoResponse] = p.future  
}

def testElasticsearchVersion: Future[Boolean] = {  
GetEsVersionQuery(esClient).execute map {  
esVersion =\> {  
val nodes = esVersion.iterator().toList  
nodes forall(node =\> node.getVersion.after(Version.V\_0\_90\_5))  
}  
} recover {  
case e: Throwable =\> false  
}  
}

Am Dienstag, 26. November 2013 15:03:31 UTC+1 schrieb Stefan Meiwald:

> I am looking for the Java API pendant to
> 
> curl -XGET [http://localhost:9200](http://localhost:9200)
> 
> With a Result like:
> 
> ```
> {
> "ok" : true, 
> "status" : 200,
> "name" : "Kierrok",
> "version" : {
> "number" : "0.90.7",
> "build_hash" : "36897d07dadcb70886db7f149e645ed3d44eb5f2",
> "build_timestamp" : "2013-11-13T12:06:54Z",
> "build_snapshot" : false,
> "lucene_version" : "4.5.1"
> },
> "tagline" : "You Know, for Search"
> 
> ```
> 
> }
> 
> Actually its only about the version. I want to write a test which ensures  
> that I am using a version \>= 0.90.5

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:04am UTC](https://discuss.elastic.co/t/get-elasticsearch-version-with-java-api/14599/4 "2017-07-06T02:04:47Z")

</div>


