0Pricing
Elasticsearch & Full Text Search Systems · Lesson

Synonyms and Stemming

Improve recall in full-text search by teaching Elasticsearch about word variants and equivalents using stemming token filters and synonym filters.

Synonyms and Stemming is a free Elasticsearch & Full Text Search Systems lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Elasticsearch & Full Text Search Systems learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Closing the Vocabulary Gap

Users rarely type the exact words stored in your documents. They search running but your text says run, or they type laptop when the doc says notebook. Two analysis techniques bridge this gap: stemming and synonyms.

What Stemming Does

Stemming reduces words to a common root form. running, runs, and ran may all become run. This means a query matches regardless of the grammatical form used.

Algorithmic Stemmers

Elasticsearch ships algorithmic stemmers like porter_stem and the language-aware stemmer filter. They apply rules to strip suffixes quickly without a dictionary.

"filter": {
  "my_stemmer": {
    "type": "stemmer",
    "language": "english"
  }
}

Dictionary Stemmers

Dictionary stemmers such as hunspell use real word lists for more accurate, linguistically correct roots. They are slower and need dictionary files but avoid over-stemming.

Over- and Under-Stemming

Stemming has failure modes:

  • Over-stemming: unrelated words map to the same root (e.g. universe and university).
  • Under-stemming: related words fail to share a root.

Use keyword_marker to protect specific words from stemming.

What Synonyms Do

Synonyms map words with the same meaning to each other. Searching tv can match television. They are applied via a synonym token filter in the analyzer chain.

"filter": {
  "my_synonyms": {
    "type": "synonym",
    "synonyms": [ "tv, television", "laptop, notebook" ]
  }
}

Equivalent vs Explicit

Synonym rules come in two styles:

  • Equivalent (tv, television): all terms are interchangeable.
  • Explicit (i-pod => ipod, music player): the left maps to the right only.

Index-Time vs Search-Time

Synonyms can be applied when indexing or when searching. Search-time synonyms (via synonym_graph) are preferred because you can update the list without re-indexing the whole corpus.

"filter": {
  "graph_syns": {
    "type": "synonym_graph",
    "synonyms_path": "analysis/synonyms.txt"
  }
}

Multi-Word Synonyms

Multi-word synonyms like ny, new york need the graph-aware synonym_graph filter at search time to be tokenized correctly. The older synonym filter mishandles phrases.

Combining Both

A typical chain applies synonyms first, then stemming, after lowercasing. Order matters: stem after expanding synonyms so all variants get normalized consistently.

"my_analyzer": {
  "tokenizer": "standard",
  "filter": [ "lowercase", "graph_syns", "my_stemmer" ]
}

Testing With _analyze

Always verify your chain with the _analyze API to confirm the produced tokens match your expectations before relying on it in production.

GET my_index/_analyze
{
  "analyzer": "my_analyzer",
  "text": "running televisions"
}

Quick Check

Test your understanding of recall-boosting filters.

Recap

You learned to widen search recall:

  • Stemming reduces word forms to a shared root; watch for over/under-stemming.
  • Synonyms map equivalent terms; equivalent vs explicit rules behave differently.
  • Prefer synonym_graph at search time for editable, multi-word-safe synonyms.
  • Verify analyzer output with the _analyze API.

Frequently asked questions

Is the “Synonyms and Stemming” lesson free?

Yes — the full text of “Synonyms and Stemming” is free to read here on the web, and the Elasticsearch & Full Text Search Systems course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Elasticsearch & Full Text Search Systems course, upgrade to CoddyKit PRO.

What will I learn in “Synonyms and Stemming”?

Improve recall in full-text search by teaching Elasticsearch about word variants and equivalents using stemming token filters and synonym filters. You practise Elasticsearch & Full Text Search Systems with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Elasticsearch & Full Text Search Systems?

No prior experience is required. Elasticsearch & Full Text Search Systems on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Synonyms and Stemming” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Elasticsearch & Full Text Search Systems lesson?

Yes. Every Elasticsearch & Full Text Search Systems lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Analyzers, Tokenizers, Filters
  2. Customizing Text Analyzers
  3. Boosting and Relevancy Scoring
  4. Synonyms and Stemming
← Back to Elasticsearch & Full Text Search Systems