elastic / elastic/elasticsearch-java

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

Open
#283 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
524
Forks
300
Avg merge
1d 11h
Merged PRs (30d)
16

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.'
at co.elastic.clients.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:76)
at co.elastic.clients.elasticsearch._types.Time.(Time.java:97)
at co.elastic.clients.elasticsearch._types.Time.(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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.