Elasticsearch: add a synonym filter on my english analyser Elasticsearch: add a synonym filter on my english analyser elasticsearch elasticsearch

Elasticsearch: add a synonym filter on my english analyser


Yes, you should define a custom analyzer. You can start with the standard English analyzer, and add your synonymfilter to 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 as whether it will diverge, yes. If you are applying your synonyms as index time, newly indexed data will have the synonym filter applied, existing data will not. If you want changes to index-time analysis to apply consistently, you need to re-index the data.

If the change to analysis will only only be in your search_analyzer, then there is no need to re-index.