【问题标题】:Create a default index template for all indices in elasticsearch 5.2在 elasticsearch 5.2 中为所有索引创建默认索引模板
【发布时间】:2017-03-06 12:26:25
【问题描述】:

我正在寻找一种方法来默认为所有创建的索引设置与索引相关的属性。

以前使用 elasticsearch 2 我有这样的行:

index.number_of_replicas: 0
index.merge.scheduler.size_thread_count: 1
index.number_of_shards: 1

在节点配置 YAML 中。现在节点配置中不允许索引相关配置,那么如何在弹性搜索启动时应用所有这些设置?

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    好的,看来我找到了解决方案,以下是向所有索引添加全局设置的方法:

    准备工作:

    Node node = new Node(nodeSettings.build()).start();
    Client client = node.client();
    

    然后:

    new PutIndexTemplateRequest("my-template-name")
                        .template("*")
                        .create(true)
                        .settings(indicesSettings.build());
    client.admin().indices().putTemplate(request).actionGet();
    

    【讨论】:

      猜你喜欢
      • 2021-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-09
      相关资源
      最近更新 更多