# Java API - what is the correct way of updating the settings

**URL:** <https://discuss.elastic.co/t/java-api-what-is-the-correct-way-of-updating-the-settings/100455>\
**Category:** Elasticsearch\
**Created:** [September 14, 2017, 5:32am UTC](https://discuss.elastic.co/t/java-api-what-is-the-correct-way-of-updating-the-settings/100455 "2017-09-14T05:32:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AntonQUT](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@AntonQUT](https://discuss.elastic.co/u/AntonQUT)\
**Post date:** [September 14, 2017, 5:32am UTC](https://discuss.elastic.co/t/java-api-what-is-the-correct-way-of-updating-the-settings/100455/1 "2017-09-14T05:32:35Z")

</div>

I am using the java API version 5.3 and want to know the non-deprecated way of updating the index settings. Currently I use:

```
		final UpdateSettingsResponse response = _myClient.admin().indices().prepareUpdateSettings().setSettings(newSettingsAsJson).setIndices(indexName).execute().actionGet();

```

But setSettings is deprecated as far as Eclipse is telling me.

Could you please tell me the new way of doing this?  
Thanks

---

<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:** [September 14, 2017, 6:06am UTC](https://discuss.elastic.co/t/java-api-what-is-the-correct-way-of-updating-the-settings/100455/2 "2017-09-14T06:06:34Z")

</div>

Probably you need to set that the content you sent is JSON.

> <https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsRequestBuilder.java#L76>

`.setSettings(newSettingsAsJson, XContentType.JSON)` from the top of my head.

---

<div class="post-metadata">

**Author:** ![AntonQUT](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@AntonQUT](https://discuss.elastic.co/u/AntonQUT)\
**Post date:** [September 15, 2017, 12:01am UTC](https://discuss.elastic.co/t/java-api-what-is-the-correct-way-of-updating-the-settings/100455/3 "2017-09-15T00:01:42Z")

</div>

Correct - that worked, thank you.

---

<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:** [October 13, 2017, 12:01am UTC](https://discuss.elastic.co/t/java-api-what-is-the-correct-way-of-updating-the-settings/100455/4 "2017-10-13T00:01:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
