AI Hints
Home›Elasticsearch Tutorial›Stemming, Synonyms and Custom Analyzers
Elasticsearch · Lesson 55 of 120

Stop Words and Stemming

Jackets finds jacket.

⏱ 2 min read▶ Video at 51:42🎓 Free
Watch this lesson in the Elasticsearch courseWatch on YouTube ↗Full Elasticsearch course

Remember the old search? Waterproof jackets found nothing, because of the plural. Stemming fixes that. It cuts words down to a root, so jackets and jacket become the same term.

  • jackets ≠ jacket?
  • Stemming
  • Same root

The english analyzer

The english analyzer stems words, and removes common stop words. Run it. Jackets became jacket, keeps became keep, and boots became boot. And the stop words, the and for, are gone.

Dev Tools Consoletext
GET _analyze?filter_path=tokens.token
{
  "analyzer": "english",
  "text": "The jackets keeps you dry for hiking boots"
}
Output
{
  "tokens": [
    {"token": "jacket"},
    {"token": "keep"},
    {"token": "you"},
    {"token": "dry"},
    {"token": "hike"},
    {"token": "boot"}
  ]
}

Search with stems

The catalog fixture uses the english analyzer on names. Now search for jackets, plural. Run it. All seven jackets match, even though every name says jacket.

Dev Tools Consoletext
GET products/_search?filter_path=hits.total.value
{
  "query": { "match": { "name": "jackets" } }
}
Output
{"hits": {"total": {"value": 7}}}
Also uses _load
catalog

Summary

The english analyzer stems words and drops stop words, so plurals and verb forms match. Next, synonyms.

Key takeaways
  • Stemming
  • Stop words
  • english analyzer
Next up: Synonyms — coat means jacket