es模板
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 |
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模板的更多相关文章
- es 模板
{ "template": "log*", "order":10, "settings": { "index& ...
- elasticsearch 动态模板设置
自定义动态映射 如果你想在运行时增加新的字段,你可能会启用动态映射.然而,有时候,动态映射 规则 可能不太智能.幸运的是,我们可以通过设置去自定义这些规则,以便更好的适用于你的数据. 日期检测 当 E ...
- es简单介绍及使用注意事项
是什么? Elasticsearch是一个基于Apache Lucene(TM)的开源搜索引擎.无论在开源还是专有领域,Lucene可以被认为是迄今为止最先进.性能最好的.功能最全的搜索引擎库. El ...
- 使用Logstash创建ES映射模版并进行数据默认的动态映射规则
本文配置为 ELK 即(Elasticsearch.Logstash.Kibana)5.5.1. Elasticsearch 能够自动检测字段的类型并进行映射,例如引号内的字段映射为 String,不 ...
- elasticsearch 动态模板
在elasticsearch中,如果你有一类相似的数据字段,想要统一设置其映射,就可以用到一项功能:动态模板映射(dynamic_templates). 每个模板都有一个名字用于描述这个模板的用途,一 ...
- Logstash动态模板映射收集Nginx的Json格式日志
Logstash传输给ES的数据会自动映射为5索引,5备份,字段都为text的的索引.这样基本上无法进行数据分析.所以必须将Logstash的数据按照既定的格式存储在ES中,这时候就要使用到ES模板技 ...
- Elasticsearch笔记
资料 官网: http://www.elasticsearch.org 中文资料:http://www.learnes.net/ .Net驱动: http://nest.azurewebsites.n ...
- 分布式实时日志处理平台ELK
这三样东西分别作用是:日志收集.索引与搜索.可视化展现 l logstash 这张架构图可以看出logstash只是collect和index的地方,运行时传入一个.conf文件,配置分三部分:in ...
- elasticsearch映射
前面讲到,无论是关系型数据库还是非关系型数据库,乃至elasticsearch这种事实上承担着一定储存作用的搜索引擎,数据类型都是非常重要而基础的概念.但elasticsearch与其它承担着数据存储 ...
随机推荐
- UVA 10340 All in All(字符串,朴素匹配)
#include <stdio.h> #include <algorithm> #include <cstring> using namespace std; ], ...
- aoj 0033 Ball【dfs/枚举】
有一个形似央视大楼(Orz)的筒,从A口可以放球,放进去的球可通过挡板DE使其掉进B裤管或C裤管里,现有带1-10标号的球按给定顺序从A口放入,问是否有一种控制挡板的策略可以使B裤管和C裤管中的球从下 ...
- 2018 ACM-ICPC 南京网络赛
Problem A Problem B Problem C Problem D Problem E Problem F Problem G Problem H Problem I Problem J ...
- 学懂grid布局:这篇就够了(译)
上周发过一篇关于flex布局的文章,但发完之后我感觉我并没有写很多自己对flex布局的理解,因为原链接的作者的轮子实在是太强了,这里借用知乎大佬牛岱的话来说,当人家已经有足够好的轮子,你就不要试图,甚 ...
- 初识.NET Core
dotnet new console dotnet new web dotnet new webapi dotnet run dotnet build -r win-x64 dotnet publis ...
- Xamarin XAML语言教程控件模板的模板绑定
Xamarin XAML语言教程控件模板的模板绑定 控件模板的模板绑定 为了可以轻松更改控件模板中控件上的属性值,可以在控件模板中实现模板绑定功能.模板绑定允许控件模板中的控件将数据绑定到公共属性上. ...
- 【枚举】bzoj1800 [Ahoi2009]fly 飞行棋
暴力枚举. #include<cstdio> #include<algorithm> using namespace std; ],sum[],half,ans; int qu ...
- NPOI读取Excel2003,2007
using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Lin ...
- python 爬取36K新闻
代码如下: from urllib import request url = 'http://36kr.com/api/info-flow/newsflash_columns/newsflashes? ...
- SVN安装中遇到的问题
新的版本:1.9.5 必须使用Apache Portable Runtime Utility 1.5.4 Released没有安装的话需要先安装 需要安装apr.apr-util sqlite zli ...