Analyzers, tokenizers and token filters
The chain that turns a string into terms, and why it must be the same on both sides.
Open this lesson in the learning hubKey points
- An analyzer is three stages: zero or more character filters, exactly one tokenizer, then token filters.
- The default
standardanalyzer splits on Unicode word boundaries and lowercases, with no stopwords. - Run
POST _analyzeto see the exact tokens a chain produces before you index anything. - The same analyzer runs at index time and query time, or the two sets of terms never line up.
search_analyzeroverrides the query side deliberately - index with edge ngrams, query plain.- A
keywordfield skips analysis completely, so the whole value becomes one single term.
Example
POST /_analyze
{
"tokenizer": "standard",
"filter": ["lowercase", "porter_stem"],
"text": "The Cafes were RUNNING"
}
# tokens: [the, cafe, were, run]
# standard tokenizer -> The, Cafes, were, RUNNING
# lowercase -> the, cafes, were, running
# porter_stem -> cafes becomes cafe, running becomes run
If a search returns nothing, run _analyze on both the field value and the query text first.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Elasticsearch Course course, and every lesson in it is listed on the Elasticsearch Course contents page.