AI Hints
Home›Elasticsearch Tutorial›Text Analysis
Elasticsearch · Lesson 54 of 120

Built-in Analyzers

Standard, simple, keyword.

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

Elasticsearch comes with many analyzers ready to use. Picking the right one can fix a search problem without writing any custom code.

  • Many built in
  • Pick the right one
  • No code

Three analyzers, one text

We analyze the same product code with three analyzers. Standard keeps the numbers. Simple drops everything that isn't a letter. Keyword keeps the whole text as one term. Run it.

Dev Tools Consoletext
GET _analyze?filter_path=tokens.token
{ "analyzer": "standard", "text": "TH-500 Trail Pack" }

GET _analyze?filter_path=tokens.token
{ "analyzer": "simple", "text": "TH-500 Trail Pack" }

GET _analyze?filter_path=tokens.token
{ "analyzer": "keyword", "text": "TH-500 Trail Pack" }
Output
# GET _analyze 200 OK
{
  "tokens": [
    {"token": "th"},
    {"token": "500"},
    {"token": "trail"},
    {"token": "pack"}
  ]
}

# GET _analyze 200 OK
{
  "tokens": [
    {"token": "th"},
    {"token": "trail"},
    {"token": "pack"}
  ]
}

# GET _analyze 200 OK
{"tokens": [{"token": "TH-500 Trail Pack"}]}

Which analyzer?

Standard is a good default for most languages. Simple splits on anything that isn't a letter. Whitespace only splits on spaces. Keyword doesn't split at all. And language analyzers, like English, add stemming and stop words.

keyvalue
standardgood default
simpleletters only
whitespacesplit on spaces
keywordno split
english+ stemming

Summary

Built-in analyzers include standard, simple, whitespace, keyword and many languages. Next, stop words and stemming.

Key takeaways
  • standard
  • simple
  • keyword
Next up: Stop Words and Stemming — jackets finds jacket