# Elasticsearch Java Client does not return Cluster Settings

**URL:** <https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773>\
**Category:** Elasticsearch\
**Created:** [January 9, 2016, 6:15am UTC](https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773 "2016-01-09T06:15:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![riki](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@riki](https://discuss.elastic.co/u/riki)\
**Post date:** [January 9, 2016, 6:15am UTC](https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773/1 "2016-01-09T06:15:54Z")

</div>

I would like to read the Cluster Settings using ES Java Client. I have tried the following code but it always returns an empty settings:

```
`Settings settings = client.admin().cluster().prepareState().execute().actionGet().getState().getMetaData().settings();`

```

But if I edit a Setting value using ES Java Client and then after executing the above code, I get only that Setting

Is there a way to get all Cluster Settings using ES Java Client?

---

<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:** [January 9, 2016, 8:16am UTC](https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773/2 "2016-01-09T08:16:34Z")

</div>

IIRC you can only access to explicit settings you defined. If you are using default settings, then this will return empty.

---

<div class="post-metadata">

**Author:** ![riki](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@riki](https://discuss.elastic.co/u/riki)\
**Post date:** [January 9, 2016, 10:42am UTC](https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773/3 "2016-01-09T10:42:55Z")

</div>

Thanks David.

My requirement is to get the value of '_discovery.zen.ping.unicast.hosts_'. Is there any other API which gives me this information?

So if we can't read the default settings, then is it a good idea to write a plugin which will read elasticsearch.yml and create an index for storing all the values? And from the created index, I can read the settings?

---

<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:** [January 9, 2016, 11:04am UTC](https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773/4 "2016-01-09T11:04:22Z")

</div>

Did you set this settings?

If not, it defaults to ::1

[https://www.elastic.co/guide/en/elasticsearch/reference/2.1/modules-discovery-zen.html#unicast](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/modules-discovery-zen.html#unicast)

---

<div class="post-metadata">

**Author:** ![riki](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@riki](https://discuss.elastic.co/u/riki)\
**Post date:** [January 9, 2016, 11:20am UTC](https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773/5 "2016-01-09T11:20:45Z")

</div>

Yes, I have set it.

Now I have 1 Master Node (1), 1 Master/Data Node (2) and 1 Data Node (3). All nodes 'discovery.zen.ping.unicast.hosts' setting points to (1). Now I would like to programmatically set another master node (2). Before I set I need to know what is the existing value and then I need to update the elasticsearch.yml file and restart all the nodes.

---

<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:** [January 9, 2016, 12:16pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773/6 "2016-01-09T12:16:27Z")

</div>

`discovery.zen.ping.unicast.hosts` is a node level settings IIRC. It does not belong to the cluster level settings. So you can't set it cluster wise.

You need to change it in `config/elasticsearch.yml` and restart the node I think.

---

<div class="post-metadata">

**Author:** ![riki](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@riki](https://discuss.elastic.co/u/riki)\
**Post date:** [January 9, 2016, 4:14pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773/7 "2016-01-09T16:14:51Z")

</div>

Fine, thanks for the clarification. I was under assumption that it's a Cluster Settings. As you said, I need to update elasticsearch.yml file, that I already thought of.

Again coming back to same question, how can I read the settings specified in elasticsearch.yml file through ES Java API? Is the only way to implement through a Custom Plugin, which will read the file when ES Nodes starts and put it in one Index?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 9, 2016, 10:13pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773/8 "2016-01-09T22:13:43Z")

</div>

There's no way to read this info from the APIs at the moment, though [https://github.com/elastic/elasticsearch/issues/10713](https://github.com/elastic/elasticsearch/issues/10713) may be of interest.

---

<div class="post-metadata">

**Author:** ![riki](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@riki](https://discuss.elastic.co/u/riki)\
**Post date:** [January 10, 2016, 4:34am UTC](https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773/9 "2016-01-10T04:34:26Z")

</div>

Thanks Mark for the link

---

<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, 11:25pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-does-not-return-cluster-settings/38773/10 "2017-07-05T23:25:42Z")

</div>


