0
0
Elasticsearchquery~5 mins

Testing analyzers (_analyze API) in Elasticsearch

Choose your learning style9 modes available
Introduction

Testing analyzers helps you see how text is broken down and processed before searching. It shows how your search engine understands words.

You want to check how your text is split into words (tokens).
You want to see which parts of words are kept or removed.
You want to test if your custom analyzer works as expected.
You want to debug why some search results are missing.
You want to understand how filters like lowercase or stop words affect text.
Syntax
Elasticsearch
POST /_analyze
{
  "analyzer": "standard",
  "text": "Your text here"
}

Use POST method with the /_analyze endpoint.

Specify the analyzer name and the text to test inside the JSON body.

Examples
This tests the built-in standard analyzer on the text.
Elasticsearch
POST /_analyze
{
  "analyzer": "standard",
  "text": "Quick Brown Fox"
}
This uses a whitespace tokenizer and lowercase filter to see tokens.
Elasticsearch
POST /_analyze
{
  "tokenizer": "whitespace",
  "filter": ["lowercase"],
  "text": "Hello World"
}
This tests the analyzer configured in your index my_index.
Elasticsearch
POST /my_index/_analyze
{
  "text": "Testing custom analyzer"
}
Sample Program

This example sends a request to Elasticsearch to analyze the sentence using the standard analyzer. It will show how the sentence is split into tokens.

Elasticsearch
POST /_analyze
{
  "analyzer": "standard",
  "text": "The Quick Brown Fox"
}
OutputSuccess
Important Notes

You can test any analyzer or tokenizer configured in your Elasticsearch setup.

Use this API to quickly check how text is processed without indexing data.

Summary

Use /_analyze to see how text is split into tokens.

It helps debug and understand your search text processing.

You can test built-in or custom analyzers easily.