liveBook · Manning

Analyze API

As explained in Elasticsearch in Action, Second Edition

The Elasticsearch analyze API analyzes supplied text and returns the terms and intermediate results produced by an analyzer.

The analyze API lets you inspect how Elasticsearch processes text before indexing. Use it to choose an analyzer, explain unexpected search results, and test analysis before production. section 7.2.4

Inspecting “James Bond 007”

GET _analyze { "text": "James Bond 007" } With no analyzer specified, Elasticsearch uses the standard analyzer. The response produces the lowercase tokens “james”, “bond”, and “007”, along with token types and positions. section 7.2.4

Specify an analyzer to compare alternatives. The simple analyzer returns “james” and “bond” because “007” is truncated at a non-letter character; the english analyzer returns “jame”, “bond”, and “007” through stemming. section 7.2.4

Testing a custom analyzer

GET _analyze { "tokenizer": "path_hierarchy", "filter": ["uppercase"], "text": "/Volumes/FILES/Dev" } The request can provide its tokenizer and token filters directly, making it useful for experimenting with custom analysis modules. section 4.5.1

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Shows tokens, lowercase conversion, token types, positions, explicit analyzers, stemming, tokenizers, and filters.
Examples
Uses “James Bond 007”, standard, simple, and english analyzers, plus a path hierarchy tokenizer with an uppercase filter.
What it assumes
Assumes basic Elasticsearch text fields and search concepts while demonstrating analysis stages and analyzer behavior through examples.
What you can do after
Diagnose search analysis with the _analyze endpoint and compare or prototype analyzer configurations before deployment.
How it connects
Connects analyzers with tokenizers, character filters, token filters, stemming, text fields, indexing, and search queries.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.