gpt4 book ai didi

elasticsearch - 创建 ElasticSearch 动态模板以确保所有字段都设置为 not_analyzed

转载 作者:行者123 更新时间:2023-11-29 02:55:44 28 4
gpt4 key购买 nike

我有一个 ElasticSearch 类型,我希望为其动态设置映射。我想分析该类型的几个选择字段,但其他所有内容都应设置为“not_analyzed”。

我想出了以下片段。这会将所有 string 字段设置为不进行分析,但不涵盖所有其他数据类型。我尝试使用文档中显示的“通用”字段,但没有帮助。谁能告诉我如何才能做到这一点?

{
"TypeName": {
"dynamic_templates": [
{
"template_name": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"index": "no",
"type": "string"
}
}
}
],
"dynamic": true,
"properties": {
"url": {
"index": "analyzed",
"type": "string"
},
"resourceUrl": {
"index": "analyzed",
"type": "string"
}
}
}
}

最佳答案

{
"mappings": {
"TypeName": {
"dynamic_templates": [
{
"base": {
"mapping": {
"index": "not_analyzed"
},
"match": "*",
"match_mapping_type": "*"
}
}
],
"dynamic": true,
"properties": {
"url": {
"index": "analyzed",
"type": "string"
},
"resourceUrl": {
"index": "analyzed",
"type": "string"
}
}
}
}
}

总体而言,索引级模板:

{
"mappings": {
"_default_": {
"dynamic_templates": [
{
"base": {
"mapping": {
"index": "not_analyzed"
},
"match": "*",
"match_mapping_type": "*"
}
}
]
}
}
}

关于elasticsearch - 创建 ElasticSearch 动态模板以确保所有字段都设置为 not_analyzed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31280683/

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