Get tokens from text analysis

  • POST also GET /{index}/_analyze
  • POST also GET /_analyze
Auth

The analyze API performs analysis on a text string and returns the resulting tokens.

Generating excessive amount of tokens may cause a node to run out of memory. The index.analyze.max_token_count setting enables you to limit the number of tokens that can be produced. If more than this limit of tokens gets generated, an error occurs. The _analyze endpoint without a specified index will always use 10000 as its limit.

Learn more about text analysis

Required authorization

Index privileges index

Path parameters

index string optional

Index used to derive the analyzer. If specified, the analyzer or field parameter overrides this value. If no index is specified or the index does not have a default analyzer, the analyze API uses the standard analyzer.

Leave it out to use /_analyze.

Query parameters

index string

Index used to derive the analyzer. If specified, the analyzer or field parameter overrides this value. If no index is specified or the index does not have a default analyzer, the analyze API uses the standard analyzer.

Request body

analyzer string

The name of the analyzer that should be applied to the provided text. This could be a built-in analyzer, or an analyzer that’s been configured in the index.

attributes string[]

Array of token attributes used to filter the output of the explain parameter.

char_filter object[]

Array of character filters used to preprocess characters before the tokenizer.

explain boolean · default: false

If true, the response includes token attributes and additional details.

field string

Field used to derive the analyzer. To use this parameter, you must specify an index. If specified, the analyzer parameter overrides this value.

filter object[]

Array of token filters used to apply after the tokenizer.

normalizer string

Normalizer to use to convert text into a single token.

text union oneOf

Text to analyze. If an array of strings is provided, it is analyzed as a multi-value field.

One of: string[] or string
tokenizer object

Tokenizer to use to convert text into tokens.

Response

application/json
detail object
analyzer object
name string required
tokens object[] required
bytes string required
end_offset number required
keyword boolean
position number required
positionLength number required
start_offset number required
termFrequency number required
token string required
type string required
charfilters object[]
filtered_text string[] required
name string required
custom_analyzer boolean required
tokenfilters object[]
name string required
tokens object[] required
bytes string required
end_offset number required
keyword boolean
position number required
positionLength number required
start_offset number required
termFrequency number required
token string required
type string required
tokenizer object
Same fields as tokenfilters in detail
tokens object[]
end_offset number required
position number required
positionLength number
start_offset number required
token string required
type string required