Index Templatesedit

Index templates allow you to define templates that will automatically be applied to new indices created. The templates include both settings and mappings, and a simple pattern template that controls if the template will be applied to the index created. For example:

curl -XPUT localhost:9200/_template/template_1 -d '
{
"template" : "te*",
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : false }
}
}
}
'

Defines a template named template_1, with a template pattern of te*. The settings and mappings will be applied to any index name that matches the te* template.

It is also possible to include aliases in an index template as follows:

curl -XPUT localhost:9200/_template/template_1 -d '
{
"template" : "te*",
"settings" : {
"number_of_shards" : 1
},
"aliases" : {
"alias1" : {},
"alias2" : {
"filter" : {
"term" : {"user" : "kimchy" }
},
"routing" : "kimchy"
},
"{index}-alias" : {}

    }
}
'

the {index} placeholder within the alias name will be replaced with the actual index name that the template gets applied to during index creation.

Deleting a Templateedit

Index templates are identified by a name (in the above case template_1) and can be deleted as well:

curl -XDELETE localhost:9200/_template/template_1

Getting templatesedit

Index templates are identified by a name (in the above case template_1) and can be retrieved using the following:

curl -XGET localhost:9200/_template/template_1

You can also match several templates by using wildcards like:

curl -XGET localhost:9200/_template/temp*
curl -XGET localhost:9200/_template/template_1,template_2

To get list of all index templates you can run:

curl -XGET localhost:9200/_template/

Templates existsedit

Used to check if the template exists or not. For example:

curl -XHEAD -i localhost:9200/_template/template_1

The HTTP status code indicates if the template with the given name exists or not. A status code 200means it exists, a 404 it does not.

Multiple Template Matchingedit

Multiple index templates can potentially match an index, in this case, both the settings and mappings are merged into the final configuration of the index. The order of the merging can be controlled using the order parameter, with lower order being applied first, and higher orders overriding them. For example:

curl -XPUT localhost:9200/_template/template_1 -d '
{
"template" : "*",
"order" : 0,
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : false }
}
}
}
' curl -XPUT localhost:9200/_template/template_2 -d '
{
"template" : "te*",
"order" : 1,
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : true }
}
}
}
'

The above will disable storing the _source on all type1 types, but for indices of that start with te*, source will still be enabled. Note, for mappings, the merging is "deep", meaning that specific object/property based mappings can be added/overridden on higher order templates, with lower order templates providing the basis.

参考官网

tips:有时候修改了配置文件参数,也修改了线上参数还是出现报错,有可能是模板没改,导致每次新生成索引的时候报错,比如:单机的时候

number_of_replicas不为0,生成的索引就会报错。

查看模板:curl -XGET 'http://10.0.120.39:9200/_template/webstat_download_tmp'

es模板的更多相关文章

  1. es 模板

    { "template": "log*", "order":10, "settings": { "index& ...

  2. elasticsearch 动态模板设置

    自定义动态映射 如果你想在运行时增加新的字段,你可能会启用动态映射.然而,有时候,动态映射 规则 可能不太智能.幸运的是,我们可以通过设置去自定义这些规则,以便更好的适用于你的数据. 日期检测 当 E ...

  3. es简单介绍及使用注意事项

    是什么? Elasticsearch是一个基于Apache Lucene(TM)的开源搜索引擎.无论在开源还是专有领域,Lucene可以被认为是迄今为止最先进.性能最好的.功能最全的搜索引擎库. El ...

  4. 使用Logstash创建ES映射模版并进行数据默认的动态映射规则

    本文配置为 ELK 即(Elasticsearch.Logstash.Kibana)5.5.1. Elasticsearch 能够自动检测字段的类型并进行映射,例如引号内的字段映射为 String,不 ...

  5. elasticsearch 动态模板

    在elasticsearch中,如果你有一类相似的数据字段,想要统一设置其映射,就可以用到一项功能:动态模板映射(dynamic_templates). 每个模板都有一个名字用于描述这个模板的用途,一 ...

  6. Logstash动态模板映射收集Nginx的Json格式日志

    Logstash传输给ES的数据会自动映射为5索引,5备份,字段都为text的的索引.这样基本上无法进行数据分析.所以必须将Logstash的数据按照既定的格式存储在ES中,这时候就要使用到ES模板技 ...

  7. Elasticsearch笔记

    资料 官网: http://www.elasticsearch.org 中文资料:http://www.learnes.net/ .Net驱动: http://nest.azurewebsites.n ...

  8. 分布式实时日志处理平台ELK

    这三样东西分别作用是:日志收集.索引与搜索.可视化展现 l  logstash 这张架构图可以看出logstash只是collect和index的地方,运行时传入一个.conf文件,配置分三部分:in ...

  9. elasticsearch映射

    前面讲到,无论是关系型数据库还是非关系型数据库,乃至elasticsearch这种事实上承担着一定储存作用的搜索引擎,数据类型都是非常重要而基础的概念.但elasticsearch与其它承担着数据存储 ...

随机推荐

  1. Problem C: 机器翻译【stl-队列】

    Problem C: 机器翻译 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 54  Solved: 27[Submit][Status][Web Bo ...

  2. Dfs【p4306(bzoj 2208)】 [JSOI2010]连通数

    Description 度量一个有向图恋情情况的一个指标是连通,指途中可达点对的个数. 下图的连通数是14 现在要你求出连通数 Input 输入数据第一行是图顶点的数量,一个正整数N. 接下来N行,每 ...

  3. 洛谷——P3913 车的攻击

    P3913 车的攻击 题目描述 N \times NN×N 的国际象棋棋盘上有KK 个车,第ii个车位于第R_iRi​行,第C_iCi​ 列.求至少被一个车攻击的格子数量. 车可以攻击所有同一行或者同 ...

  4. shell 查看 具体某行的值

    sed: sed '5!d' file awk: awk 'NR==5' file

  5. POJ 3180 The Cow Prom(SCC)

    [题目链接] http://poj.org/problem?id=3180 [题目大意] N头牛,M条有向绳子,能组成几个歌舞团?要求顺时针逆时针都能带动舞团内所有牛. [题解] 等价于求点数大于1的 ...

  6. 直接拿来用!最火的iOS开源项目(二)

    每一次的改变总意味着新的开始.”这句话用在iOS上可谓是再合适不过的了.GitHub上的iOS开源项目数不胜数,iOS每一次的改变,总会引发iOS开源项目的演变,从iOS 1.x到如今的iOS 7,有 ...

  7. SpringBoot项目设置热部署

    记录一个SpringBoot 设置热部署(修改项目之后,项目自动重启)实例 POM.XML 文件 <!-- 配置springBoot项目的热部署启动 --> <dependency& ...

  8. DELPHI MAKEWORD的用法

    WORD MAKEWORD(    BYTE bLow,  // low-order byte of short value    BYTE bHigh  // high-order byte of ...

  9. 【转载】网络攻击技术(三)——Denial Of Service & 哈希相关 & PHP语言 & Java语言

    找到了这个系列的原始作者: http://www.cnblogs.com/rush/archive/2012/02/05/2339037.html 最近网络安全成了一个焦点,除了国内明文密码的安全事件 ...

  10. SpringMvc(注解)上传文件的简单例子

    spring mvc(注解)上传文件的简单例子,这有几个需要注意的地方1.form的enctype=”multipart/form-data” 这个是上传文件必须的2.applicationConte ...