# Java API client : How to reset index settings value

**URL:** <https://discuss.elastic.co/t/java-api-client-how-to-reset-index-settings-value/329059>\
**Category:** Elasticsearch\
**Tags:** language-clients, runtime-fields\
**Created:** [March 31, 2023, 1:51pm UTC](https://discuss.elastic.co/t/java-api-client-how-to-reset-index-settings-value/329059 "2023-03-31T13:51:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MathieuLacour](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathieulacour/32/119289_2.png) [@MathieuLacour](https://discuss.elastic.co/u/MathieuLacour)\
**Post date:** [March 31, 2023, 1:51pm UTC](https://discuss.elastic.co/t/java-api-client-how-to-reset-index-settings-value/329059/1 "2023-03-31T13:51:17Z")

</div>

For performance reasons, I need to temporarily disable refresh\_interval at index settings level while bulk loading takes place in the index, and enable it back afterwards.  
The refresh\_interval value is held by global cluster settings and set at 1s.

I managed to _set_ an index setting value with Java API Client :

```auto
javaApiClient.indices().putSettings(
        new PutIndicesSettingsRequest.Builder()
                .index(indexName)
                .settings(
                        new IndexSettings.Builder()
                                .refreshInterval(new Time.Builder().time("-1").build())
                                .build())
                .build());

```

After bulk loading, I need to revert this, i.e. remove the refresh\_interval entry from my index settings.  
Looking at the [REST API documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html#reset-index-setting), resetting an index setting value is done by PUTting a null value for it.

```auto
PUT /my-index-000001/_settings
{
  "index" : {
    "refresh_interval" : null
  }
}

```

As I understand, once the setting is null at index level, the index will inherit the default setting value from the global settings again.  
Unfortunately, doing so with the Java API Client didn't work :

```auto
ElasticClient.get().indices().putSettings(
        new PutIndicesSettingsRequest.Builder()
                .index(indexName)
                .settings(new IndexSettings.Builder()
                                .refreshInterval((Time)null)
                                .build())
                .build());

```

I get this error at runtime :

```auto
co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/indices.put_settings] failed: [action_request_validation_exception] Validation Failed: 1: no settings to update;
  at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:281)
  at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:147)
  at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.putSettings(ElasticsearchIndicesClient.java:1442)

```

Is there a way to reset an index setting by setting it to null using the java API 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:** [March 31, 2023, 2:30pm UTC](https://discuss.elastic.co/t/java-api-client-how-to-reset-index-settings-value/329059/2 "2023-03-31T14:30:21Z")

</div>

@swallez could you look at this? Is there a way to do it?

---

<div class="post-metadata">

**Author:** ![swallez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swallez/32/11972_2.png) [@swallez](https://discuss.elastic.co/u/swallez)\
**Post date:** [March 31, 2023, 3:02pm UTC](https://discuss.elastic.co/t/java-api-client-how-to-reset-index-settings-value/329059/3 "2023-03-31T15:02:40Z")

</div>

This is currently not supported. I opened [Allow sending the `null` value where it has a specific meaning · Issue #549 · elastic/elasticsearch-java · GitHub](https://github.com/elastic/elasticsearch-java/issues/549) for this.

---

<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:** [April 28, 2023, 3:03pm UTC](https://discuss.elastic.co/t/java-api-client-how-to-reset-index-settings-value/329059/4 "2023-04-28T15:03:08Z")

</div>

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