Search code examples
elasticsearchfull-text-searchsearch-enginesynonym

ElasticSearch Multiword synonyms


I have analyzer with synonyms

{
  "settings": {
    "analysis": {
      "filter": {
        "synonyms": {
          "type": "synonym", 
      "synonyms": [
        "st,str,street",             
        "district of columbia,dc"
      ]
    }
      },
      "analyzer": {
        "synonyms": {
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "synonyms" 
          ]
        }
      }
    }
  }
}

If I run analysis on "street", it gives me that "st" and "str" are synonyms.

But if I run on "DC", it gives me that "district", "of" and "columbia" are synonyms.

How to make "DC" and "District of Columbia" synonyms ?


Solution

  • Provide the synonyms as below :

    "filter": {
        "synonyms": {
          "type": "synonym", 
          "synonyms": [
             "st,str,street",             
              "district of columbia,dc=>dc"
           ]
        }
    }
    

    Please check the reference for more details