elasticsearch mapping简单介绍
这两天一直在看elasticsearch相关的内容,看到mapping这一块,就折腾了下。
一般情况下,我们不需要对elasticsearch的mapping进行设置,但如果希望对索引使用自定义的管理,那么就需要了解这一块的内容了。这里是我在Logstash中对elasticsearch的设置.
这里是Logstash的配置:
output {
if [type] == "test" {
elasticsearch {
hosts => ["10.1.0.12:9200"]
index => "test"
document_type => "%{[@metadata][type]}"
manage_template => true
template_overwrite => true
template_name => "json_php_mapping"
template => "/usr/local/services/logstash/templates/test.json"
}
}
}
这里注意:index,template_name,template
index: 在elasticsearch上索引的名字
template_name: 使用elasticsearch上_template下的模板(与template关联不大)
template:在_template下生成模板。
下面是test.json:
{
"template": "test",
"settings":{
"index.number_of_shards": 5,
"number_of_replicas": 1,
"index.refresh_interval":"60s"
},
"mappings" : {
"_default_": {
"_all": {"enabled": false},
"dynamic": true,
"date_detection": true,
"dynamic_date_formats": [
"date_optional_time||epoch_millis||epoch_second",
"yyyy-MM-dd'T'HH:mm:ssZZ.SSS||yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.SSS"
],
"dynamic_templates": [{
"date":{
"match_mapping_type": "date",
"match": "date_*",
"mapping":{
"type": "date"
}
}
},{
"strings": {
"match_mapping_type": "string",
"match": "s_*",
"mapping":{
"type": "keyword",
"ignore_above": 256
}
}
},{
"long": {
"match_mapping_type":"*",
"match": "l_*",
"mapping":{
"type": "integer"
}
}
},
{
"double": {
"match_mapping_type": "*",
"match": "d_*",
"mapping": {
"type": "double"
}
}
},
{
"analyzer": {
"match": "t_*",
"mapping": {
"type": "text",
"index": true,
"analyzer": "english"
}
}
},
{
"ip": {
"match_mapping_type": "*",
"match": "ip_*",
"mapping": {
"type": "ip"
}
}
}
]
}
}
}
参数解释:
template: 这里是模板的名字,可以在kibana中使用:GET _template 来查看es下的所有模板
settings: 一般设置分片。 index.refresh_interval 一般是用户将segments刷新到磁盘缓存的时间间隔,默认是1s
_default_: index中的type中使用默认的这个mapping.注意:在6.0版本后特性被移除
dynamic: 开启动态模板
date_detection: 打开时间格式的识别
dynamic_date_formats: 可以识别的时间格式
dynamic_templates下定义:
"dynamic_templates": [
{
"my_template_name": {
... match conditions ...
"mapping": { ... }
}
},
...
]
my_template_name:就是给下面match取得名字,没什么作用。
match conditions: (https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html)
1. match_mapping_type :匹配字段的类型。通过类型匹配字段
2. match: 匹配字段,通过正则匹配字段
3. match_pattern: 一般与上面的match使用,用于正则
还有一些插入时间es自动生成的,如@timestamp,_type,version等等,差不多就这样了。
官网关于这一块介绍的很容易理解,建议看官网,下面的连接是本文中最关键的:https://www.elastic.co/guide/en/elasticsearch/reference
elasticsearch mapping简单介绍的更多相关文章
- ELK学习实验004:Elasticsearch的简单介绍和操作
一 集群节点 Elstaicsearch的集群是由多个节点组成都,通过cluster.name设置集权名称,比能切用与区分其他的集群,每个节点通过node.name指定节点 在Elasticsearc ...
- ElasticSearch实战系列四: ElasticSearch理论知识介绍
前言 在前几篇关于ElasticSearch的文章中,简单的讲了下有关ElasticSearch的一些使用,这篇文章讲一下有关 ElasticSearch的一些理论知识以及自己的一些见解. 虽然本人是 ...
- Elasticsearch7.X 入门学习第五课笔记---- - Mapping设定介绍
原文:Elasticsearch7.X 入门学习第五课笔记---- - Mapping设定介绍 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本 ...
- ElasticSearch API 简要介绍
调用其API会返回很多信息,例如集群的信息,节点的信息等 检查集群的状态----Restful API说明 1:检查集群状态信息 2:管理集群 3:执行 增删改查 命令 4:执行高级命令 Restfu ...
- Elasticsearch教程(五) elasticsearch Mapping的创建
一.Mapping介绍 在Elasticsearch中,Mapping是什么? mapping在Elasticsearch中的作用就是约束. 1.数据类型声明 它类似于静态语言中的数据类型声明,比如声 ...
- springboot简单介绍
1.springboot简单介绍 微服务架构 Spring Boot 是由 Pivotal 团队提供的全新框架,其设计目的是用来简化新 Spring 应用的初始搭建以及开发过程. 该框架使用了特定的方 ...
- Frame Relay - 简单介绍及基本配置
Frame Relay如今越来越不流行了,只是在过去的设计中被广泛应用. 所以工作上还是能常常见到的, 这篇博文从二层简单总结下FR的一些概念 在介绍Frame Relay之前,先了解下广播介质和非广 ...
- Hibernate学习(1)简单介绍
1.什么是Hibernate? 首先,Hibernate是数据持久层的一个轻量级框架.数据持久层的框架有非常多比方:iBATIS,myBatis,Nhibernate,Siena等 ...
- Java泛型使用的简单介绍
目录 一. 泛型是什么 二. 使用泛型有什么好处 三. 泛型类 四. 泛型接口 五. 泛型方法 六. 限定类型变量 七. 泛型通配符 7.1 上界通配符 7.2 下界通配符 7.3 无限定通配符 八. ...
随机推荐
- TensorFlow:谷歌图像识别网络inception-v3下载与查看结构
学习博客: # https://www.cnblogs.com/felixwang2/p/9190731.html # https://www.cnblogs.com/felixwang2/p/919 ...
- mysql int类型字段插入空字符串时自动转为0
mysql int类型字段插入空字符串时自动转为0 如果不想转的话可以修改配置文件 修改 my.ini 文件. # Set the SQL mode to strictsql-mode=”STRICT ...
- netty笔记-:Channel与ChannelHandlerContext执行write方法的区别
在netty中有我们一般有两种发送数据的方式,即使用ChannelHandlerContext或者Channel的write方法,这两种方法都能发送数据,那么其有什么区别呢.这儿引用netty文档 ...
- Java方法升级
1. 方法格式 package cn.itcast.day04.demo02; /* 方法其实就是若干语句的功能集合. 方法好比是一个工厂. 蒙牛工厂 原料:奶牛.饲料.水 产出物:奶制品 钢铁工厂 ...
- 基于Amoeba读写分离
Amoeba 原理:amoeba相当于业务员,处理client的读写请求,并将读写请求分开处理.amoeba和master以及slave都有联系,如果是读的请求,amoeba就从slave读取信息反馈 ...
- 八、ORDER BY优化
前言:在使用order by时,经常出现Using filesort,因此对于此类sql语句需尽力优化,使其尽量使用Using index. 0.准备 #1.创建test表. drop table i ...
- 使用python实现归并排序、快速排序、堆排序
归并排序 使用分治法:分而治之 分: 递归地拆分数组,直到它被分成两对单个元素数组为止. 然后,将这些单个元素中的每一个与它的对合并,然后将这些对与它们的对等合并,直到整个列表按照排序顺序合并为止. ...
- python 切片技巧
说明: 字符串[开始索引:结束索引:步长] 开始索引:从指定位置开始截取: 结束索引:从指定位置结束截取,但不包含该位置的字符. 步长:不指定时步长为1: 1)当步长为正数时候,那么切片是从左到右进行 ...
- docker部署-windows环境
docker部署-windows环境 1. docker windows 1.1. 安装 win7或者win8需要利用docker toolbox来安装,其是一个docker工具集,w ...
- ZOJ1006 Do the Untwist
简单模拟~ #include<bits/stdc++.h> using namespace std; ; int a[maxn]; unordered_map<char,int> ...