【发布时间】:2020-09-19 11:39:00
【问题描述】:
Dynamic templates 允许您定义可应用于动态添加的字段的自定义映射:
- Elasticsearch 检测到的数据类型,带有 match_mapping_type。
- 字段的名称,包括 match 和 unmatch 或 match_pattern。
- 字段的完整虚线路径,包含 path_match 和 path_unmatch。
我试图为所有字段设置默认类型 keyword,而某些具有特定 *Suffix 或 prefix* 的特殊字段可以指定如下类型,但事实证明所有字段都将是 keyword意外结束。
{
"order": 99,
"index_patterns": [
"xxxx_stats_*"
],
"settings": {
"index": {
"number_of_shards": "6",
"number_of_replicas": "1"
}
},
"mappings": {
"_doc": {
"dynamic": true,
"_source": {
"enabled": true
},
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "*",
"unmatch": [
"*Time",
"*At",
"is*"
],
"mapping": {
"ignore_above": 256,
"null_value": "NULL",
"type": "keyword"
}
}
},
{
"timeSuffix": {
"match_mapping_type": "*",
"match": [
"*Time",
"*At"
],
"mapping": {
"type": "long"
}
}
},
{
"isPrefix": {
"match_mapping_type": "*",
"match": "is*",
"mapping": {
"type": "boolean"
}
}
}
],
"date_detection": false,
"numeric_detection": true
}
},
"aliases": {
"{index}-alias": {
}
}
}
【问题讨论】:
标签: elasticsearch mapping