A synonym lets search treat different words or phrases as equivalent. Without synonym handling, a query for “passion” may miss text containing the related term “cognizance”; with it, varied user vocabulary can produce more relevant results. section 7.1.1 section 1.3.1
Synonyms support search behavior in several ways:
- Map alternate names such as “soccer” and “football” so either query can point to a football game. section 7.8.3
- Enrich normalization alongside stemming and stop-word handling before terms are added to the inverted index. section 7.2.2
- Address vocabulary variation that exact matching, including traditional database search, may fail to understand. section 1.2.3
Configure a synonym filter
Create an index analysis filter with a rule such as “soccer => football”. Test the configured analyzer with “What’s soccer?” through the _analyze API; the analyzed output includes “football”, showing that the synonym was applied. For larger or changing synonym sets, load rules from synonyms.txt through synonyms_path instead of hardcoding them. section 7.8.3
Listing 7.52 Creating an index with a synonym filter
PUT index_with_synonyms
{
"settings": {
"analysis": {
"filter": {
"synonyms_filter":{
"type":"synonym",
"synonyms":[ "soccer => football"]
}
}
}
}
}
Shows the Elasticsearch index settings needed to define a synonym token filter and map soccer to football. section 7.8.3

