indexing - Elasticsearch: add a synonym filter on my english analyser -
i've got index field description analysed that:
"description":{ "analyzer" : "english", "type" : "string" }
i have defined synonyms dictionnary in file synonyms.txt contain:
ipod, i-pod, pod => i-pod
i add synonym dictionnary analyzer, don't know how it. should define custom analyzer? if diverge current indexation due customisation.index
yes, should define custom analyzer. can start standard english analyzer, , add synonymfilter that:
{ "settings": { "analysis": { "filter": { "english_stop": { "type": "stop", "stopwords": "_english_" }, "english_keywords": { "type": "keyword_marker", "keywords": [] }, "english_stemmer": { "type": "stemmer", "language": "english" }, "english_possessive_stemmer": { "type": "stemmer", "language": "possessive_english" }, "my_synonyms" : { "type" : "synonym", "synonyms_path" : "path/to/synonym.txt" } }, "analyzer": { "custom_english": { "tokenizer": "standard", "filter": [ "english_possessive_stemmer", "lowercase", "my_synonyms", "english_stop", "english_keywords", "english_stemmer" ] } } } } }
as far whether diverge, yes. if applying synonyms index time, newly indexed data have synonym filter applied, existing data not. if want changes index-time analysis apply consistently, need re-index data.
if change analysis only in search_analyzer
, there no need re-index.
Comments
Post a Comment