我正在尝试将同义词过滤器添加到我的 Elasticsearch 分析器中。确切地说,我需要将同义词添加到索引分析器中,因为我使用模糊搜索,并且希望它也能识别同义词中的拼写错误。
但是当我尝试创建索引分析器时:
"filter": {
"synonyms": {
"type": "synonym_graph",
"synonyms": [
...
]
}
}
"index_analyzer": {
"tokenizer": "standard",
"filter": ["lowercase", "synonyms", "edge_ngram"]
}
然后将其指定为字段的索引分析器:
"text" : {
"type" : "text",
"analyzer": "index_analyzer",
"search_analyzer": "search_analyzer"
}
我收到一个错误:
{
"error" : {
"root_cause" : [
{
"type" : "mapper_exception",
"reason" : "analyzer [index_analyzer] contains filters [synonyms] that are not allowed to run in index time mode."
}
],
"type" : "mapper_parsing_exception",
"reason" : "Failed to parse mapping [_doc]: analyzer [index_analyzer] contains filters [synonyms] that are not allowed to run in index time mode.",
"caused_by" : {
"type" : "mapper_exception",
"reason" : "analyzer [index_analyzer] contains filters [synonyms] that are not allowed to run in index time mode."
}
},
"status" : 400
}
尽管Elasticsearch 文档说:
您可以将包含同义词集的分析器指定为搜索时间分析器或索引时间分析器。
我做错了什么?Elastisearch 版本是 7.17.5。
以上句子适用于 ES 版本
v8.10
及更高版本。您无法在版本上使用索引时间分析器v7.17
https://www.elastic.co/guide/en/elasticsearch/reference/current/release-notes-8.10.0.html