1. 定制dynamic策略
> true:遇到陌生字段,就進行dynamic mapping
> false:遇到陌生字段,就忽略
> strict:遇到陌生字段,就報錯
~~~
PUT /my_index
{
"mappings": {
"my_type": {
"dynamic": "strict", # 插入不存在的字段,報錯
"properties": {
"title": {
"type": "text"
},
"address": {
"type": "object",
"dynamic": "true" # 遇到不存在的字段,自動映射
}
}
}
}
}
~~~
~~~
PUT /my_index/my_type/1
{
"title": "my article",
"content": "this is my article",
"address": {
"province": "guangdong",
"city": "guangzhou"
}
}
~~~
報錯:因為插入了不存在的字段
~~~
{
"error": {
"root_cause": [
{
"type": "strict_dynamic_mapping_exception",
"reason": "mapping set to strict, dynamic introduction of [content] within [my_type] is not allowed"
}
],
"type": "strict_dynamic_mapping_exception",
"reason": "mapping set to strict, dynamic introduction of [content] within [my_type] is not allowed"
},
"status": 400
}
~~~
因為address設置"dynamic": "true" 允許插入不存在的字段,并自動mapping,插入成功
~~~
PUT /my_index/my_type/1
{
"title": "my article",
"address": {
"province": "guangdong",
"city": "guangzhou"
}
}
~~~
~~~
GET /my_index/_mapping/my_type
{
"my_index": {
"mappings": {
"my_type": {
"dynamic": "strict", # 整個type的dynamic:strict,不允許插入不存在的字段
"properties": {
"address": {
"dynamic": "true", # address的dynamic為true,所以address字段中允許插入新的字段
"properties": {
"city": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"province": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"title": {
"type": "text"
}
}
}
}
}
}
~~~
2. 定制dynamic mapping策略
(1)date\_detection
> 默認會按照一定格式識別date,比如yyyy-MM-dd。但是如果某個field先過來一個2017-01-01的值,就會被自動dynamic mapping成date,后面如果再來一個"hello world"之類的值,就會報錯。可以手動關閉某個type的date\_detection,如果有需要,自己手動指定某個field為date類型。
~~~
PUT /my_index/_mapping/my_type
{
"date_detection": false
}
~~~
(2)定制自己的dynamic mapping template(type level)
~~~
PUT /my_index
{
"mappings": {
"my_type": {
"dynamic_templates": [
{ "en": {
"match": "*_en", # 索引下,復合這個模式的field,就用這個模板映射
"match_mapping_type": "string",
"mapping": {
"type": "string", # 把符合模式的字段映射成string類型
"analyzer": "english" # 把符合模式的字段的分詞器設置成english(排除頻繁詞)
}
}}
]
}}}
~~~
~~~
PUT /my_index/my_type/1
{
"title": "this is my first article"
}
~~~
~~~
PUT /my_index/my_type/2
{
"title_en": "this is my first article"
}
~~~
~~~
title沒有匹配到任何的dynamic模板,默認就是standard分詞器,不會過濾停用詞,is會進入倒排索引,用is來搜索是可以搜索到的
title_en匹配到了dynamic模板,就是english分詞器,會過濾停用詞,is這種停用詞就會被過濾掉,用is來搜索就搜索不到了
~~~
(3)定制自己的default mapping template(index level)
~~~
PUT /my_index
{
"mappings": {
"_default_": {
"_all": { "enabled": false }
},
"blog": {
"_all": { "enabled": true }
}
}
}
~~~
- springcloud
- springcloud的作用
- springboot服務提供者和消費者
- Eureka
- ribbon
- Feign
- feign在微服務中的使用
- feign充當http請求工具
- Hystrix 熔斷器
- Zuul 路由網關
- Spring Cloud Config 分布式配置中心
- config介紹與配置
- Spring Cloud Config 配置實戰
- Spring Cloud Bus
- gateway
- 概念講解
- 實例
- GateWay
- 統一日志追蹤
- 分布式鎖
- 1.redis
- springcloud Alibaba
- 1. Nacos
- 1.1 安裝
- 1.2 特性
- 1.3 實例
- 1. 整合nacos服務發現
- 2. 整合nacos配置功能
- 1.4 生產部署方案
- 環境隔離
- 原理講解
- 1. 服務發現
- 2. sentinel
- 3. Seata事務
- CAP理論
- 3.1 安裝
- 分布式協議
- 4.熔斷和降級
- springcloud與alibba
- oauth
- 1. abstract
- 2. oauth2 in micro-service
- 微服務框架付費
- SkyWalking
- 介紹與相關資料
- APM系統簡單對比(zipkin,pinpoint和skywalking)
- server安裝部署
- agent安裝
- 日志清理
- 統一日志中心
- docker安裝部署
- 安裝部署
- elasticsearch 7.x
- logstash 7.x
- kibana 7.x
- ES索引管理
- 定時清理數據
- index Lifecycle Management
- 沒數據排查思路
- ELK自身組件監控
- 多租戶方案
- 慢查詢sql
- 日志審計
- 開發
- 登錄認證
- 鏈路追蹤
- elk
- Filebeat
- Filebeat基礎
- Filebeat安裝部署
- 多行消息Multiline
- how Filebeat works
- Logstash
- 安裝
- rpm安裝
- docker安裝Logstash
- grok調試
- Grok語法調試
- Grok常用表達式
- 配置中常見判斷
- filter提取器
- elasticsearch
- 安裝
- rpm安裝
- docker安裝es
- 使用
- 概念
- 基礎
- 中文分詞
- 統計
- 排序
- 倒排與正排索引
- 自定義dynamic
- 練習
- nested object
- 父子關系模型
- 高亮
- 搜索提示
- kibana
- 安裝
- docker安裝
- rpm安裝
- 整合
- 收集日志
- 慢sql
- 日志審計s
- 云
- 分布式架構
- 分布式鎖
- Redis實現
- redisson
- 熔斷和降級