在尝试添加术语方面时,我遇到了以下问题:术语被标记为单独的单词。例如,如果属性(字段)Kind
具有值medium kind of shirt
和large kind of shirt
,则这些术语变为-medium
,large
,kind
,of
,shirt
。
为了解决这个问题,建议我更改映射,以便为每个属性字段包括"index": "not_analyzed"
。问题是映射是动态生成的,例如-:
"attributes": {
"properties": {
"kind": {
"type": "string"
},
"color": {
"type": "string"
},
"size": {
"type": "string"
}
}
}
简单地将
"not_analyzed"
中的"attributes"
位置1并不会。有没有办法为attributes
字段内的每个子字段设置索引属性?
最佳答案
感谢Andrei的评论,我能够弄清楚如何应用设置。
我在映射中添加了一个dynamic_templates
部分,如下所示:
"dynamic_templates": [
{
"string_template": {
"path_match": "attributes.*",
"match_mapping_type": "string",
"mapping": {
"type": "string",
"index": "not_analyzed"
}
}
}
]
这可以解决问题,现在每个
"string"
类型的子字段都有自己的"index"
设置为"not_analyzed"
。这些条款不再标记化。
关于elasticsearch - 为字段的所有子字段设置 'index'属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27937630/