简体   繁体   English

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

[英]How change global elasticsearch index creation setting?

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

Install elastic by this tutorial https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html :通过本教程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"
}

How globally change some index creation options https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html ?如何全局更改某些索引创建选项https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html Such as index.max_ngram_diff as example?比如index.max_ngram_diff为例?

You need to use the index update settings API :您需要使用索引更新设置 API

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

If you want this setting to be applied on index that are going to be created in the future, you can create an index template that will be applied to the matching future indexes:如果您希望将此设置应用于将来要创建的索引,您可以创建一个将应用于匹配的未来索引的索引模板

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

After that, every time that you create a new index whose name matches my-index-* , that new index will get the settings set in the template.之后,每次创建名称与my-index-*匹配的新索引时,该新索引都会获得模板中设置的设置。

I will recommend to use Index templates for this.我会建议为此使用索引模板 You can preconfigure template with settings you need, and use on index creation.您可以使用您需要的设置预配置模板,并在创建索引时使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM