dynamic mapping配置放到template使用问题
来源:4-13 -索引模板.mp4

慕村7052289
2018-12-05
老师您好,我使用如下配置创建test2模板、test_d1模板、t8_index的时候,t8_index匹配到test2模板了,没有匹配到test_d1模板,但是test_d1模板的order值比test2要大,应该优先匹配test_d1才对吧,不知道问题在哪里 请老师帮忙解答
PUT _template/test_d1
{
"index_patterns":["*_index","index_t*"],
"order":3,
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"doc" : {
"_source" : {
"enabled" : true
},
"dynamic_templates": [
{
"custom_string_to_keyword": {
"match_mapping_type": "string",
"mapping": {
"type": "keyword",
"ignore_above": 256
}
}
}
]
}
}
}
PUT _template/test2
{
"index_patterns":["*_index","index_t*"],
"order":2,
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"doc" : {
"_source" : {
"enabled" : true
},
"properties" : {
"age" : {
"type" : "integer"
},
"city" : {
"type" : "keyword"
},
"name" : {
"type" : "keyword"
},
"title" : {
"type" : "text"
}
}
}
}
}
PUT t8_index/doc/1
{
"title": "t8",
"city": "shenzhen",
"name": "Smith2",
"age": 12
}
3回答
-
你期待的是指应用test_d1吗?实际不是这样的,template在匹配到多个时会做一个合并处理,合并时如果发现多个模板设置了同一个key,那就取order值大的。你这里从dynamic template来看test-d1实际生效了
012018-12-06 -
慕村7052289
提问者
2018-12-06
GET t8_index/_mapping
{
"t8_index" : {
"mappings" : {
"doc" : {
"dynamic_templates" : [
{
"custom_string_to_keyword" : {
"match_mapping_type" : "string",
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
}
}
}
],
"properties" : {
"age" : {
"type" : "integer"
},
"city" : {
"type" : "keyword"
},
"name" : {
"type" : "keyword"
},
"title" : {
"type" : "text"
}
}
}
}
}
}
GET t8_index/_settings
{
"t8_index" : {
"settings" : {
"index" : {
"creation_date" : "1544008166309",
"number_of_shards" : "1",
"number_of_replicas" : "1",
"uuid" : "IWBeHlNhSwWs9vNml1TQ-Q",
"version" : {
"created" : "6050199"
},
"provided_name" : "t8_index"
}
}
}
}
GET t8_index/_search
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "t8_index",
"_type" : "doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"title" : "t8",
"city" : "shenzhen",
"name" : "Smith2",
"age" : 12
}
}
]
}
}
00 -
rockybean
2018-12-05
你GET t8_index 我看下你创建索引后的配置
012018-12-06
相似问题