Elasticsearch template(待续...)

动态模板

Dynamic templates allow you to define custom mappings that can be applied to dynamically added fields based on:

The original field name {name} and the detected datatype {dynamic_typetemplate variables can be used in the mapping specification as placeholders.

动态模板允许你基于以下条件来对动态增加的字段的映射进行自定义:

1. match_mapping_type 定义 ES 自动检测的数据类型

2. match、unmatch 或 match_pattern 匹配字段名称

3. path_match、path_unmatch 定义字段的全路径

参数说明

template

settings

注意事项

dynamic_templates 类型为数组,多个匹配条件要写为数据的不同元素

示例

为所有索引 (index) 的所有类型 (type) 的所有字符串类型字段(field)都设置为 not_analyzed。

curl -XPUT 'localhost:9200/_template/all' -d '
{
"order": 0,
"template": "*",
"settings": {
"index.number_of_shards": ""
},
"mappings": {
"_default_": {
"dynamic_templates": [
{
"string": {
"mapping": {
"index": "not_analyzed",
"type": "string"
},
"match_mapping_type": "string",
"match": "field_name*"
}
}
]
}
},
"aliases": {}
}
}
'
上一篇:Latex笔记-基本布局


下一篇:Arcengine效率探究之二——属性的更新(转载)