我正在尝试在弹性搜索索引中添加analyzer
和mapping
但我收到此错误;
[Error: MapperParsingException[mapping [product]]; nested: MapperParsingException[Analyzer [synonym] not found for field [name]];
我的索引名称产品和类型product.my设置 -
{
"settings": {
"products": {
"analysis":{
"analyzer":{
"synonym":{
"tokenizer": "my_ngram",
"filter":[
"synonym"
]
}
},
"tokenizer" : {
"my_ngram" : {
"type" : "nGram",
"min_gram" : "2",
"max_gram" : "3",
"token_chars": [ "letter", "digit" ]
}
},
"filter":{
"synonym": {
"type": "synonym",
"synonyms_path": "synonyms.txt",
"ignore_case": "true"
}
}
}
}
},
"mappings":{
"product":{
"_all":{
"enabled": true,
},
"properties":{
"name":{
"type": "string",
"index": "analyzed",
"analyzer": "synonym"
}
}
}
}
}
我正在使用最新版本的弹性搜索。
答案 0 :(得分:2)
假设synonyms.txt
存在,我认为这将解决您的问题:
{
"settings": {
"analysis": {
"analyzer": {
"synonym": {
"tokenizer": "my_ngram",
"filter": [
"synonym"
]
}
},
"tokenizer": {
"my_ngram": {
"type": "nGram",
"min_gram": "2",
"max_gram": "3",
"token_chars": [
"letter",
"digit"
]
}
},
"filter": {
"synonym": {
"type": "synonym",
"synonyms_path": "synonyms.txt",
"ignore_case": "true"
}
}
}
},
"mappings": {
"product": {
"_all": {
"enabled": true
},
"properties": {
"name": {
"type": "string",
"index": "analyzed",
"analyzer": "synonym"
}
}
}
}
}
您不需要"products"
中的"settings"
条目。