Skip to content
Advertisement

Solr synonym.txt adding at elasticsearch

I have already a working synonym.txt in solr. Now I want to add that same txt file at elasticseach. What can I do for it. At solr it was easy, I just keep that file in system. At elsticsearch I added this and also run some command but it is not working.

PUT /test_index
{
  "settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "synonym": {
            "tokenizer": "whitespace",
            "filter": [ "synonym" ]
          }
        },
        "filter": {
          "synonym": {
            "type": "synonym",
            "synonyms_path": "analysis/synonym.txt"
          }
        }
      }
    }
  }
}

What’s wrong I am doing? Do I need to do index again or I need to map this with any field. My search result depends on multiple field.

Advertisement

Answer

Hope you have applied your synonym on your existing fields in your ES mapping, you have just provided your index setting, and you need to provide the index mapping to confirm it.

Also adding an analyzer to the existing field is a breaking change and you have to reindex the data again to see the updated tokens.

You must use Analyze API to see the updated tokens on your index, Also please cross-check if you have added the synonym.txt properly and there was no error while creating the index setting with this file.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement