gpt4 book ai didi

java - 未应用动态映射,并且在 _mapping 中丢失

转载 作者:行者123 更新时间:2023-11-29 09:28:56 24 4
gpt4 key购买 nike

我正在尝试创建适用于字符串字段或日期字段的动态映射,

{
"xx": {
"mappings": {
"dynamic_templates": [
{
"dates": {
"match": "*",
"match_mapping_type": "date*",
"mapping": {
"type": "date",
"format": "YYYY-mm-dd",
"doc_values": true
}
},
"string_fields": {
"mapping": {
"index": "not_analyzed",
"store": false,
"doc_values": true,
"type": "string"
},
"match": "*",
"match_mapping_type": "string"
}
}
]
}
}
}

但是当我将它应用于索引时,“日期”部分丢失了,只剩下 string_fields,

enter image description here

这是怎么回事?

最佳答案

不确定您是如何将该映射应用到索引的,但是对于名为 test_index 的索引和名为 test_type 的类型,正确的方法是:

PUT /test_index
{
"mappings": {
"test_type": {
"dynamic_templates": [
{
"dates": {
"match": "*",
"match_mapping_type": "date*",
"mapping": {
"type": "date",
"format": "YYYY-mm-dd",
"doc_values": true
}
}
},
{
"string_fields": {
"mapping": {
"index": "not_analyzed",
"store": false,
"doc_values": true,
"type": "string"
},
"match": "*",
"match_mapping_type": "string"
}
}
]
}
}
}

关于java - 未应用动态映射,并且在 _mapping 中丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31150831/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com