提问者:小点点

如何更改全局弹性搜索索引创建设置?


操作系统: #1 SMP Debian 4.19.152-1 (2020-10-18)

通过本教程安装弹性 https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html:

{
  "name" : "web",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "HSeOQvkHRey2P_JN2Nv-GA",
  "version" : {
    "number" : "7.10.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "51e9d6f22758d0374a0f3f5c6e8f3a7997850f96",
    "build_date" : "2020-11-09T21:30:33.964949Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

如何全局更改某些索引创建选项 https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html?比如 index.max_ngram_diff 作为例子?


共2个答案

匿名用户

需要使用索引更新设置 API:

PUT your-index/_settings
{
  "index.max_ngram_diff": 2
}

如果要将此设置应用于将来要创建的索引,可以创建一个索引模板,该模板将应用于匹配的未来索引:

PUT /_index_template/template_1
{
  "index_patterns" : ["my-index-*"],
  "priority" : 1,
  "template": {
    "settings" : {
      "index.max_ngram_diff" : 2
    }
  }
}

之后,每次创建名称与 my-index-* 匹配的新索引时,该新索引都将获得模板中设置的设置。

匿名用户

我建议为此使用索引模板。您可以使用所需的设置预配置模板,并在创建索引时使用。