我正在嘗試在 elasticsearch 中創建一個自定義分析器。這是分析儀
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer" : "standard",
"filter" : ["custom_stopper", "custom_stems", "custom_synonyms"]
},
"filter" : {
"custom_stopper" : {
"type" : "stop",
"stopwords_path" : "analyze/stopwords.txt"
},
"custom_stems" : {
"type" : "stemmer_override",
"rules_path" : "analyze/stem.txt"
},
"custom_synonyms" : {
"type" : "synonyms",
"synonyms_path" : "analyze/synonym.txt"
}
}
}
}
}
}
但它拋出錯誤
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "analyzer [filter] must specify either an analyzer type, or a tokenizer"
}
],
"type": "illegal_argument_exception",
"reason": "analyzer [filter] must specify either an analyzer type, or a tokenizer"
},
"status": 400
}
我在這里做錯了什么?
uj5u.com熱心網友回復:
在filter必須與同一級別analyzer。
結構看起來像這樣:
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "standard",
"char_filter": [
"custom_stopper",
"custom_stems",
"custom_synonyms"
]
}
},
"filter": {
"custom_stopper": {
"type": "stop",
"stopwords_path": "analyze/stopwords.txt"
},
"custom_stems": {
"type": "stemmer_override",
"rules_path": "analyze/stem.txt"
},
"custom_synonyms": {
"type": "synonyms",
"synonyms_path": "analyze/synonym.txt"
}
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/365802.html
