I am trying to add synonyms filter to my Elasticsearch analyzer. Precisely, I need to add synonyms to the index analyzer because I use fuzzy search and want it it recongnize typos in synonyms as well.
But when I try to create index alanyzer:
"filter": {
"synonyms": {
"type": "synonym_graph",
"synonyms": [
...
]
}
}
"index_analyzer": {
"tokenizer": "standard",
"filter": ["lowercase", "synonyms", "edge_ngram"]
}
and then specify it as index analyzer for a field:
"text" : {
"type" : "text",
"analyzer": "index_analyzer",
"search_analyzer": "search_analyzer"
}
I get an error:
{
"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
}
Though Elasticsearch documentation says:
You can specify the analyzer that contains your synonyms set as a search time analyzer or as an index time analyzer.
What am I doing wrong? Elastisearch version is 7.17.5.
You can specify the analyzer that contains your synonyms set as a
search time analyzer
or as anindex time analyzer
.
The above sentence is accurate for ES version v8.10
and later. You can't use index time analyzer on version v7.17
https://www.elastic.co/guide/en/elasticsearch/reference/current/release-notes-8.10.0.html