Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#283 2 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
elasticsearch, java
领域
api, backend

调研方向

先从 issue 中所示的 Time.Builder 和 PutIndicesSettingsRequest 用法开始,然后跟踪 low-level client 如何序列化 null refresh interval。将其与 High Level Client 的请求进行比较,并确定是否支持清除设置;当行为得到修复,或已有明确文档说明并由回归测试覆盖时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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?

主要语言
Java
星标
525
派生
299
平均合并
13 小时 9 分钟
30 天内合并 PR
5

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

elastic/elasticsearch-java 的其他 Issue

查看 elastic/elasticsearch-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。