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 :
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, resetting an index setting value is done by PUTting a null value for it.
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 :
ElasticClient.get().indices().putSettings(
new PutIndicesSettingsRequest.Builder()
.index(indexName)
.settings(new IndexSettings.Builder()
.refreshInterval((Time)null)
.build())
.build());
I get this error at runtime :
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 ?