禁用动态字段的分析器
Disable analyzer for dynamic fields
在我的弹性搜索索引中,我为特定对象启用了动态映射,这意味着默认情况下会分析添加到该对象的任何 "string" 字段。
有没有办法禁用对动态字段的分析?
您需要使用匹配您的字符串字段的 'dynamic template' 并应用将字段设置为 'not_analyzed'
的映射
见http://www.elastic.co/guide/en/elasticsearch/guide/current/custom-dynamic-mapping.html
这是一个示例,该示例使该字段在已分析和未分析状态下都可用
'dynamic_templates' : [
{
'string_template' : {
'match' : '*',
'match_mapping_type' : 'string',
'mapping' : {
'type' : 'multi_field',
'fields': {
'{name}' : {'type': 'string', 'index': 'analyzed', 'analyzer' : 'default'},
'raw': { 'type': 'string', 'index': 'not_analyzed'}"
}
}
}
}
]
在我的弹性搜索索引中,我为特定对象启用了动态映射,这意味着默认情况下会分析添加到该对象的任何 "string" 字段。
有没有办法禁用对动态字段的分析?
您需要使用匹配您的字符串字段的 'dynamic template' 并应用将字段设置为 'not_analyzed'
的映射见http://www.elastic.co/guide/en/elasticsearch/guide/current/custom-dynamic-mapping.html
这是一个示例,该示例使该字段在已分析和未分析状态下都可用
'dynamic_templates' : [
{
'string_template' : {
'match' : '*',
'match_mapping_type' : 'string',
'mapping' : {
'type' : 'multi_field',
'fields': {
'{name}' : {'type': 'string', 'index': 'analyzed', 'analyzer' : 'default'},
'raw': { 'type': 'string', 'index': 'not_analyzed'}"
}
}
}
}
]