Elasticsearch_索引模板

1 索引模板中信息

  • 可套用该索引模板的索引名称格式,名称支持通配符,也可以配置多个名称格式匹配格式(index_patterns);
  • 索引的基本设置(settings);
  • 索引的字段映射(mapping)信息;
  • 别名(alias);

语法:

PUT _template/my_template
{
  "index_patterns": ...,
  "settings": {
...  
},
  "mappings": {
    ...
  }
}

2 例子

# 创建索引名字以“next-sfpay-core”开头的引用如下索引模板
PUT _template/next-sfpay-core
{
  "index_patterns": ["next-sfpay-core*"],
  "order" : 0,
  "version": 1,
  "settings": {
    "number_of_shards": 7,
    "number_of_replicas":1
  }
}
# 查看模板内容
PUT /next-sfpay-core_test?pretty
# 验证
# 创建索引next-sfpay-core_test
PUT /next-sfpay-core_test?pretty

# 查看索引分片
GET /_cat/shards/next-sfpay-core_test*
发布了20 篇原创文章 · 获赞 1 · 访问量 2889

猜你喜欢

转载自blog.csdn.net/linwenhai2018/article/details/103381510