Words with the same meaning
You may have heard about synonyms, words that have the same or similar meaning. Sometimes you would want to have some words matched when one of those words is entered into the search box. Let's recall our sample data from Chapter 3, Searching Your Data. There was a book called crime and punishment. What if we want that book to not only be matched when the words crime or punishment are used, but also when using the words such as criminality and abuse. At first glance, this may not sound like good behavior, but sometimes this is really needed, especially in use cases where there are multiple words meaning the same (like in medicine). To handle such use cases, we will use synonyms.
Synonym filter
Synonyms in Elasticsearch are handled on the analysis level – at both index and query time, by a dedicated synonyms filter. To use the synonym filter, we need to define our own analyzer. For example, let's define an analyzer that will be called synonym and will use the whitespace...