gpt4 book ai didi

elasticsearch - 在 Elasticsearch 中为单个索引实现多个synonym_path

转载 作者:行者123 更新时间:2023-12-02 23:00:05 25 4
gpt4 key购买 nike

我正在试图为Elasticsearch中的单个索引实现多个synonym_path

"settings": {
"index": {
"analysis": {
"analyzer": {
"synonym": {
"tokenizer": "whitespace",
"filter": ["synonym"]
}
},
"filter": {
"bool": {
"should": [{
"synonym": {
"type": "synonym",
"synonyms_path": "synonyms.txt",
"ignore_case": true
}},
{
"synonym": {
"type": "synonym",
"synonyms_path": "synonyms2.txt",
"ignore_case": true
}}]
}
}
}
}
},
"mappings": {
"animals": {
"properties": {
"name": {
"type": "String",
"analyzer": "synonym"
}
}
}
}

我在Chrome中使用JSON Sense尝试了上述代码段,但生成了 TokenFilter [bool] must have a type associated with it错误。

还有其他实现方法吗?

最佳答案

filter部分中的analysis部分并不意味着包含查询DSL,而是token filter定义。

对于您的情况,您需要使用以下设置重新创建索引:

{
"settings": {
"index": {
"analysis": {
"analyzer": {
"synonyms": {
"tokenizer": "whitespace",
"filter": [
"synonym1",
"synonym2"
]
}
},
"filter": {
"synonym1": {
"type": "synonym",
"synonyms_path": "synonyms.txt",
"ignore_case": true
},
"synonym2": {
"type": "synonym",
"synonyms_path": "synonyms2.txt",
"ignore_case": true
}
}
}
}
},
"mappings": {
"animals": {
"properties": {
"name": {
"type": "string",
"analyzer": "synonyms"
}
}
}
}
}

关于elasticsearch - 在 Elasticsearch 中为单个索引实现多个synonym_path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36470367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com