AI Hints
Home›Elasticsearch Tutorial›Highlighting and Suggestions
Elasticsearch · Lesson 84 of 120

Did You Mean

Fix the spelling.

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

Sometimes a search finds nothing, because of a typo. A nice search page says, did you mean sleeping? The term suggester finds similar words that really exist in your index.

  • Zero results
  • Did you mean…?
  • term suggester

Suggest a spelling

The term suggester looks at each word in the text, and finds close words in the name field. We misspell sleping and lanturn. Run it. It suggests sleeping and lantern.

Dev Tools Consoletext
GET products/_search?filter_path=suggest.*.text,suggest.*.options.text
{
  "suggest": {
    "fix": { "text": "sleping lanturn", "term": { "field": "name" } }
  }
}
Output
{
  "suggest": {
    "fix": [
      {"text": "sleping", "options": [{"text": "sleeping"}]},
      {"text": "lanturn", "options": [{"text": "lantern"}]}
    ]
  }
}
Also uses _load
products

Suggesters

The term suggester fixes words one at a time. The phrase suggester fixes a whole phrase, choosing words that go together. Completion handles prefixes. Show a suggestion only when the search found little or nothing.

keyvalue
termword by word
phrasewhole phrase
completionprefixes
Show itwhen results are few

Summary

The term suggester proposes real words close to a typo, for a did you mean link. Next, paging deep into results.

Key takeaways
  • term suggester
  • Did you mean
  • Real words
Next up: Deep Paging with search_after — past 10,000