Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Cannot clear refresh_interval of Index Setting with null using low level client

Open
#283 2 comments 3 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
elasticsearch, java
Domain
api, backend

Research direction

Start with the Time.Builder and PutIndicesSettingsRequest usage shown in the issue, then trace how a null refresh interval is serialized by the low-level client. Compare this with the High Level Client request and determine whether clearing the setting is supported; done means the behavior is fixed or clearly documented and covered by a regression test.

Written by the indexing model from the issue text.

Description

Java API client version

7.17.1

Java version

8

Elasticsearch Version

7.17.1

Problem description

Using the rest High Level Client, I was able to overwrite the refresh_interval value of an indexSetting to be the default value using the following bit of code:

UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest("accounts-index");
updateSettingsRequest.settings(Settings.builder().put("index.refresh_interval", (String) null));

try {
    restHighLevelClient.indices().putSettings(updateSettingsRequest, RequestOptions.DEFAULT);
}
catch(IOException e) {
    throw new Exception();
}

Using the low level client, I am unable to do so. If I try to run the following bit of code:

IndexSettings indexSettings = IndexSettings.of(is -> is
    .refreshInterval(Time.of(t -> t.time((String) null))));

PutIndicesSettingsRequest putIndicesSettingsRequest = PutIndicesSettingsRequest.of(pisr -> pisr
    .index(singleton("accounts-index"))
    .settings(indexSettings));

try {
    PutIndicesSettingsResponse putIndicesSettingsResponse = esClient.indices()..putSettings(putIndicesSettingsRequest);

    return putIndicesSettingsResponse.acknowledged();
}
catch (IOException e) {
    throw new Exception(e);
}

I get the exception:

co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'Builder.<variant value>'
	at co.elastic.clients.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:76)
	at co.elastic.clients.elasticsearch._types.Time.<init>(Time.java:97)
	at co.elastic.clients.elasticsearch._types.Time.<init>(Time.java:57)
	at co.elastic.clients.elasticsearch._types.Time$Builder.build(Time.java:176)
	at co.elastic.clients.elasticsearch._types.Time$Builder.build(Time.java:158)
	at co.elastic.clients.elasticsearch._types.Time.of(Time.java:102)

For now, I have reverted to setting the refresh_interval explicitly to 1 second when I want to set it to the default. I want to however switch back to being able to overwrite the refresh_interval to just be the default without explicitly setting it, ie. by passing null instead of "1s" to the Time parameter.

Is there a way to do this I am missing or is this a bug in the Time object that does not allow passing of null?

Dominant language
Java
Stars
524
Forks
299
Avg merge
16m
Merged PRs (30d)
13

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from elastic/elasticsearch-java

All issues in elastic/elasticsearch-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.