# Updating index settings by key-value pair

**URL:** <https://discuss.elastic.co/t/updating-index-settings-by-key-value-pair/308382>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [June 28, 2022, 5:19pm UTC](https://discuss.elastic.co/t/updating-index-settings-by-key-value-pair/308382 "2022-06-28T17:19:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ALX\_DM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alx_dm/32/106314_2.png) [@ALX\_DM](https://discuss.elastic.co/u/ALX_DM)\
**Post date:** [June 28, 2022, 5:19pm UTC](https://discuss.elastic.co/t/updating-index-settings-by-key-value-pair/308382/1 "2022-06-28T17:19:54Z")

</div>

In the new elasticsearch-java api client, is it possible to update a specific index setting by a key-value pair?

Say, you have these keys:

```auto
    static final String NUMBER_OF_REPLICAS_KEY = "index.number_of_replicas";
    static final String REFRESH_INTERVAL_KEY = "index.refresh_interval";

```

Then you create something like

key = REFRESH\_INTERVAL\_KEY  
value = 1200

It seems not possible with the below code

```auto
     PutIndicesSettingsRequest request = PutIndicesSettingsRequest.of(b -> b.index(indexName));
      final Map<String, Object> map = new HashMap<>();
      map.put(key, value);

      

```

Then call

```auto
    client.indices().putSettings(...)

```

Is it possible?

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [June 28, 2022, 5:42pm UTC](https://discuss.elastic.co/t/updating-index-settings-by-key-value-pair/308382/2 "2022-06-28T17:42:02Z")

</div>

Hi @ALX_DM

One way I know is the one below. Using a Map I don't know if it's possible.

```auto
    IndexSettings indexSettings = IndexSettings.of(is -> is.numberOfReplicas("2").refreshInterval(Time.of(t -> t.time("1s"))));
    PutIndicesSettingsRequest request = PutIndicesSettingsRequest.of(b -> b.index("idx_name").settings(indexSettings));
    var response = ClientUtils.getClient().indices().putSettings(request);

```

---

<div class="post-metadata">

**Author:** ![ALX\_DM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alx_dm/32/106314_2.png) [@ALX\_DM](https://discuss.elastic.co/u/ALX_DM)\
**Post date:** [June 28, 2022, 10:25pm UTC](https://discuss.elastic.co/t/updating-index-settings-by-key-value-pair/308382/3 "2022-06-28T22:25:01Z")

</div>

@RabBit_BR

I see.

HLRC can do it, but the new es api client cannot for now. Got it 👍

---

<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 26, 2022, 10:25pm UTC](https://discuss.elastic.co/t/updating-index-settings-by-key-value-pair/308382/4 "2022-07-26T22:25:33Z")

</div>

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