Search code examples
elasticsearchindexingsynonym

Elastic Search synonyms - Delete Action


Are synonyms in Elastic Search (version 6.2.3) stored in the items when these are created/updated or are synonyms applied in every search query to the index?

We need to remove the synonyms of an index with 6 million items and I cannot see in the documentation if removing these synonyms from the index will be enough

DELETE /api/as/v1/engines/{ENGINE_NAME}/synonyms/{SYNONYM_SET_ID}

Or it is needed to reindex all the items afterwards, in which case it might be better to delete the current index and create a new one.


Solution

    1. If synonyms are applied during inserting the document

      • Deletion of current synonyms, won't change anything in the existing data of an index, existing data should be searchable by synonyms.
    2. If synonyms are applied during query time

      • In this case, removing the synonyms will stop searching the document using synonym.

    Now the question is whether you are using index-time-analysis or query-time-analysis. You can check in your mappings. E.g

    "mappings": {
        "properties": {
          "text": {
            "type": "text",
            "analyzer": "autocomplete", // <======== For index time analysis
            "search_analyzer": "synonym_analyzer" //<====== For Query time analysis  
          }
        }
      }
    }