我有一个 ElasticSearch 类型,我希望为其动态设置映射。我想分析该类型上的一些选择字段,但其他所有字段都应设置为“not_analyzed”。
我想出了以下片段。这会将所有字符串字段设置为不进行分析,但不会涵盖所有其他数据类型。我尝试使用文档中显示的“通用”字段,但没有帮助。谁能告诉我如何才能做到这一点?
{
"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"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
{
"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"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
总体而言,索引级模板:
{
"mappings": {
"_default_": {
"dynamic_templates": [
{
"base": {
"mapping": {
"index": "not_analyzed"
},
"match": "*",
"match_mapping_type": "*"
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12225 次 |
| 最近记录: |