美文网首页
elastichsearch index template模板字

elastichsearch index template模板字

作者: 愤愤的有痣青年 | 来源:发表于2020-06-17 13:21 被阅读0次

索引模板(index template)是指,通过创建一些模板,使后续在创建索引时,若索引名符合模板中index_patterns字段定义的规则时,该模板的配置信息将会应用于该索引上,一般此模板可以用来配置索引的mappings和分片之类的参数.

  • 索引模板的创建方式如下:
PUT _template/template_1
{
  "index_patterns": ["te*", "bar*"],
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "_source": {
      "enabled": false
    },
    "properties": {
      "host_name": {
        "type": "keyword"
      },
      "created_at": {
        "type": "date",
        "format": "EEE MMM dd HH:mm:ss Z yyyy"
      }
    }
  }
}

说明

  • 描述
    模板中主要有两大模块,一个是映射(mappings),一个是配置(settings)
    模板中使用/**/进行注释

  • 请求方式
    PUT /_template/模板名

  • index-template
    必须 list->[string] 此字段是定义符合规则的索引名

  • create
    可选 bool 标注是否为创建模板,若为false将会更新现有模板

  • order
    可选 int如果索引与多个模板匹配,则Elasticsearch应用此模板的顺序。较低order值的模板将首先合并。较高order值的模板稍后合并,覆盖较低值的模板。

  • master_timeout
    可选 date指定等待连接到主节点的时间段。如果在超时到期之前未收到任何响应,则请求将失败并返回错误。默认为30s。

  • aliases
    可选 别名对象包括索引的索引别名

  • mappings
    可选 字段映射对象,内部有字段名 字段类型 映射参数

  • settings
    可选 索引设置对象索引的配置选项

  • version
    可选 int 用于从外部管理索引模板的版本号

本文参考至此处

相关文章

网友评论

      本文标题:elastichsearch index template模板字

      本文链接:https://www.haomeiwen.com/subject/cetsxktx.html