---
type: api
title: Get tokens from text analysis
description: The analyze API performs analysis on a text string and returns the resulting tokens.
url: https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-analyze
resource: https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-analyze
products:
  - Elasticsearch
---

# Get tokens from text analysis

Authentication: required

## Paths

- `POST` (also `GET`) `/{index}/_analyze`
- `POST` (also `GET`) `/_analyze`

#### Path parameters

- `index` (string) — optional, leave it out to use `/_analyze`
  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.

## Description

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](https://www.elastic.co/docs/manage-data/data-store/text-analysis)

## Required privileges

- Index privileges: `index`

## Query string 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.

## Request body

`application/json`

- `analyzer` (string) — optional
  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[]) — optional
  Array of token attributes used to filter the output of the `explain` parameter.
- `char_filter` (union oneOf[]) — optional
  Array of character filters used to preprocess characters before the tokenizer.
  - **string**
  - **CharFilterDefinition**
    One of:
    - **type: html_strip** (`type: html_strip`)
      - `type` (enum) — required
        Values: `html_strip`
      - `version` (string) — optional
      - `escaped_tags` (string[]) — optional
    - **type: mapping** (`type: mapping`)
      - `type` (enum) — required
        Values: `mapping`
      - `version` (string) — optional
      - `mappings` (string[]) — optional
      - `mappings_path` (string) — optional
    - **type: pattern_replace** (`type: pattern_replace`)
      - `type` (enum) — required
        Values: `pattern_replace`
      - `version` (string) — optional
      - `flags` (string) — optional
      - `pattern` (string) — required
      - `replacement` (string) — optional
    - **type: icu_normalizer** (`type: icu_normalizer`)
      - `type` (enum) — required
        Values: `icu_normalizer`
      - `version` (string) — optional
      - `mode` (enum) — optional
        Values: `decompose`, `compose`
      - `name` (enum) — optional
        Values: `nfc`, `nfkc`, `nfkc_cf`
      - `unicode_set_filter` (string) — optional
    - **type: kuromoji_iteration_mark** (`type: kuromoji_iteration_mark`)
      - `type` (enum) — required
        Values: `kuromoji_iteration_mark`
      - `version` (string) — optional
      - `normalize_kana` (boolean) — required
      - `normalize_kanji` (boolean) — required
- `explain` (boolean · default: false) — optional
  If `true`, the response includes token attributes and additional details.
- `field` (string) — optional
  Field used to derive the analyzer.
To use this parameter, you must specify an index.
If specified, the `analyzer` parameter overrides this value.
- `filter` (union oneOf[]) — optional
  Array of token filters used to apply after the tokenizer.
  - **string**
  - **TokenFilterDefinition**
    One of:
    - **type: apostrophe** (`type: apostrophe`)
      - `type` (enum) — required
        Values: `apostrophe`
      - `version` (string) — optional
    - **type: arabic_stem** (`type: arabic_stem`)
      - `type` (enum) — required
        Values: `arabic_stem`
      - `version` (string) — optional
    - **type: arabic_normalization** (`type: arabic_normalization`)
      - `type` (enum) — required
        Values: `arabic_normalization`
      - `version` (string) — optional
    - **type: asciifolding** (`type: asciifolding`)
      - `type` (enum) — required
        Values: `asciifolding`
      - `version` (string) — optional
      - `preserve_original` (boolean | string) — optional
        If `true`, emit both original tokens and folded tokens. Defaults to `false`.
    - **type: bengali_normalization** (`type: bengali_normalization`)
      - `type` (enum) — required
        Values: `bengali_normalization`
      - `version` (string) — optional
    - **type: brazilian_stem** (`type: brazilian_stem`)
      - `type` (enum) — required
        Values: `brazilian_stem`
      - `version` (string) — optional
    - **type: cjk_bigram** (`type: cjk_bigram`)
      - `type` (enum) — required
        Values: `cjk_bigram`
      - `version` (string) — optional
      - `ignored_scripts` (enum[]) — optional
        Array of character scripts for which to disable bigrams.
        Values: `han`, `hangul`, `hiragana`, `katakana`
      - `output_unigrams` (boolean) — optional
        If `true`, emit tokens in both bigram and unigram form. If `false`, a CJK character is output in unigram form when it has no adjacent characters. Defaults to `false`.
    - **type: cjk_width** (`type: cjk_width`)
      - `type` (enum) — required
        Values: `cjk_width`
      - `version` (string) — optional
    - **type: classic** (`type: classic`)
      - `type` (enum) — required
        Values: `classic`
      - `version` (string) — optional
    - **type: common_grams** (`type: common_grams`)
      - `type` (enum) — required
        Values: `common_grams`
      - `version` (string) — optional
      - `common_words` (string[]) — optional
        A list of tokens. The filter generates bigrams for these tokens.
Either this or the `common_words_path` parameter is required.
      - `common_words_path` (string) — optional
        Path to a file containing a list of tokens. The filter generates bigrams for these tokens.
This path must be absolute or relative to the `config` location. The file must be UTF-8 encoded. Each token in the file must be separated by a line break.
Either this or the `common_words` parameter is required.
      - `ignore_case` (boolean) — optional
        If `true`, matches for common words matching are case-insensitive. Defaults to `false`.
      - `query_mode` (boolean) — optional
        If `true`, the filter excludes the following tokens from the output:
- Unigrams for common words
- Unigrams for terms followed by common words
Defaults to `false`. We recommend enabling this parameter for search analyzers.
    - **type: condition** (`type: condition`)
      - `type` (enum) — required
        Values: `condition`
      - `version` (string) — optional
      - `filter` (string[]) — required
        Array of token filters. If a token matches the predicate script in the `script` parameter, these filters are applied to the token in the order provided.
      - `script` (string) — required
        Predicate script used to apply token filters. If a token matches this script, the filters in the `filter` parameter are applied to the token.
    - **type: czech_stem** (`type: czech_stem`)
      - `type` (enum) — required
        Values: `czech_stem`
      - `version` (string) — optional
    - **type: decimal_digit** (`type: decimal_digit`)
      - `type` (enum) — required
        Values: `decimal_digit`
      - `version` (string) — optional
    - **type: delimited_payload** (`type: delimited_payload`)
      - `type` (enum) — required
        Values: `delimited_payload`
      - `version` (string) — optional
      - `delimiter` (string) — optional
        Character used to separate tokens from payloads. Defaults to `|`.
      - `encoding` (enum) — optional
        Data type for the stored payload.
        Values: `int`, `float`, `identity`
    - **type: dutch_stem** (`type: dutch_stem`)
      - `type` (enum) — required
        Values: `dutch_stem`
      - `version` (string) — optional
    - **type: edge_ngram** (`type: edge_ngram`)
      - `type` (enum) — required
        Values: `edge_ngram`
      - `version` (string) — optional
      - `max_gram` (number) — optional
        Maximum character length of a gram. For custom token filters, defaults to `2`. For the built-in edge_ngram filter, defaults to `1`.
      - `min_gram` (number) — optional
        Minimum character length of a gram. Defaults to `1`.
      - `side` (enum) — optional
        Indicates whether to truncate tokens from the `front` or `back`. Defaults to `front`.
        Values: `front`, `back`
      - `preserve_original` (boolean | string) — optional
        Emits original token when set to `true`. Defaults to `false`.
    - **type: elision** (`type: elision`)
      - `type` (enum) — required
        Values: `elision`
      - `version` (string) — optional
      - `articles` (string[]) — optional
        List of elisions to remove.
To be removed, the elision must be at the beginning of a token and be immediately followed by an apostrophe. Both the elision and apostrophe are removed.
For custom `elision` filters, either this parameter or `articles_path` must be specified.
      - `articles_path` (string) — optional
        Path to a file that contains a list of elisions to remove.
This path must be absolute or relative to the `config` location, and the file must be UTF-8 encoded. Each elision in the file must be separated by a line break.
To be removed, the elision must be at the beginning of a token and be immediately followed by an apostrophe. Both the elision and apostrophe are removed.
For custom `elision` filters, either this parameter or `articles` must be specified.
      - `articles_case` (boolean | string) — optional
        If `true`, elision matching is case insensitive. If `false`, elision matching is case sensitive. Defaults to `false`.
    - **type: fingerprint** (`type: fingerprint`)
      - `type` (enum) — required
        Values: `fingerprint`
      - `version` (string) — optional
      - `max_output_size` (number) — optional
        Maximum character length, including whitespace, of the output token. Defaults to `255`. Concatenated tokens longer than this will result in no token output.
      - `separator` (string) — optional
        Character to use to concatenate the token stream input. Defaults to a space.
    - **type: flatten_graph** (`type: flatten_graph`)
      - `type` (enum) — required
        Values: `flatten_graph`
      - `version` (string) — optional
    - **type: french_stem** (`type: french_stem`)
      - `type` (enum) — required
        Values: `french_stem`
      - `version` (string) — optional
    - **type: german_normalization** (`type: german_normalization`)
      - `type` (enum) — required
        Values: `german_normalization`
      - `version` (string) — optional
    - **type: german_stem** (`type: german_stem`)
      - `type` (enum) — required
        Values: `german_stem`
      - `version` (string) — optional
    - **type: hindi_normalization** (`type: hindi_normalization`)
      - `type` (enum) — required
        Values: `hindi_normalization`
      - `version` (string) — optional
    - **type: hunspell** (`type: hunspell`)
      - `type` (enum) — required
        Values: `hunspell`
      - `version` (string) — optional
      - `dedup` (boolean) — optional
        If `true`, duplicate tokens are removed from the filter’s output. Defaults to `true`.
      - `dictionary` (string) — optional
        One or more `.dic` files (e.g, `en_US.dic`, my_custom.dic) to use for the Hunspell dictionary.
By default, the `hunspell` filter uses all `.dic` files in the `<$ES_PATH_CONF>/hunspell/<locale>` directory specified using the `lang`, `language`, or `locale` parameter.
      - `locale` (string) — required
        Locale directory used to specify the `.aff` and `.dic` files for a Hunspell dictionary.
      - `longest_only` (boolean) — optional
        If `true`, only the longest stemmed version of each token is included in the output. If `false`, all stemmed versions of the token are included. Defaults to `false`.
    - **type: hyphenation_decompounder** (`type: hyphenation_decompounder`)
      - `type` (enum) — required
        Values: `hyphenation_decompounder`
      - `version` (string) — optional
      - `max_subword_size` (number) — optional
        Maximum subword character length. Longer subword tokens are excluded from the output. Defaults to `15`.
      - `min_subword_size` (number) — optional
        Minimum subword character length. Shorter subword tokens are excluded from the output. Defaults to `2`.
      - `min_word_size` (number) — optional
        Minimum word character length. Shorter word tokens are excluded from the output. Defaults to `5`.
      - `only_longest_match` (boolean) — optional
        If `true`, only include the longest matching subword. Defaults to `false`.
      - `word_list` (string[]) — optional
        A list of subwords to look for in the token stream. If found, the subword is included in the token output.
Either this parameter or `word_list_path` must be specified.
      - `word_list_path` (string) — optional
        Path to a file that contains a list of subwords to find in the token stream. If found, the subword is included in the token output.
This path must be absolute or relative to the config location, and the file must be UTF-8 encoded. Each token in the file must be separated by a line break.
Either this parameter or `word_list` must be specified.
      - `hyphenation_patterns_path` (string) — required
        Path to an Apache FOP (Formatting Objects Processor) XML hyphenation pattern file.
This path must be absolute or relative to the `config` location. Only FOP v1.2 compatible files are supported.
      - `no_sub_matches` (boolean) — optional
        If `true`, do not match sub tokens in tokens that are in the word list. Defaults to `false`.
      - `no_overlapping_matches` (boolean) — optional
        If `true`, do not allow overlapping tokens. Defaults to `false`.
    - **type: indic_normalization** (`type: indic_normalization`)
      - `type` (enum) — required
        Values: `indic_normalization`
      - `version` (string) — optional
    - **type: keep_types** (`type: keep_types`)
      - `type` (enum) — required
        Values: `keep_types`
      - `version` (string) — optional
      - `mode` (enum) — optional
        Indicates whether to keep or remove the specified token types.
        Values: `include`, `exclude`
      - `types` (string[]) — required
        List of token types to keep or remove.
    - **type: keep** (`type: keep`)
      - `type` (enum) — required
        Values: `keep`
      - `version` (string) — optional
      - `keep_words` (string[]) — optional
        List of words to keep. Only tokens that match words in this list are included in the output.
Either this parameter or `keep_words_path` must be specified.
      - `keep_words_case` (boolean) — optional
        If `true`, lowercase all keep words. Defaults to `false`.
      - `keep_words_path` (string) — optional
        Path to a file that contains a list of words to keep. Only tokens that match words in this list are included in the output.
This path must be absolute or relative to the `config` location, and the file must be UTF-8 encoded. Each word in the file must be separated by a line break.
Either this parameter or `keep_words` must be specified.
    - **type: keyword_marker** (`type: keyword_marker`)
      - `type` (enum) — required
        Values: `keyword_marker`
      - `version` (string) — optional
      - `ignore_case` (boolean) — optional
        If `true`, matching for the `keywords` and `keywords_path` parameters ignores letter case. Defaults to `false`.
      - `keywords` (union string | string[]) — optional
        Array of keywords. Tokens that match these keywords are not stemmed.
This parameter, `keywords_path`, or `keywords_pattern` must be specified. You cannot specify this parameter and `keywords_pattern`.
      - `keywords_path` (string) — optional
        Path to a file that contains a list of keywords. Tokens that match these keywords are not stemmed.
This path must be absolute or relative to the `config` location, and the file must be UTF-8 encoded. Each word in the file must be separated by a line break.
This parameter, `keywords`, or `keywords_pattern` must be specified. You cannot specify this parameter and `keywords_pattern`.
      - `keywords_pattern` (string) — optional
        Java regular expression used to match tokens. Tokens that match this expression are marked as keywords and not stemmed.
This parameter, `keywords`, or `keywords_path` must be specified. You cannot specify this parameter and `keywords` or `keywords_pattern`.
    - **type: keyword_repeat** (`type: keyword_repeat`)
      - `type` (enum) — required
        Values: `keyword_repeat`
      - `version` (string) — optional
    - **type: kstem** (`type: kstem`)
      - `type` (enum) — required
        Values: `kstem`
      - `version` (string) — optional
    - **type: length** (`type: length`)
      - `type` (enum) — required
        Values: `length`
      - `version` (string) — optional
      - `max` (number) — optional
        Maximum character length of a token. Longer tokens are excluded from the output. Defaults to `Integer.MAX_VALUE`, which is `2^31-1` or `2147483647`.
      - `min` (number) — optional
        Minimum character length of a token. Shorter tokens are excluded from the output. Defaults to `0`.
    - **type: limit** (`type: limit`)
      - `type` (enum) — required
        Values: `limit`
      - `version` (string) — optional
      - `consume_all_tokens` (boolean) — optional
        If `true`, the limit filter exhausts the token stream, even if the `max_token_count` has already been reached. Defaults to `false`.
      - `max_token_count` (number | string) — optional
        Maximum number of tokens to keep. Once this limit is reached, any remaining tokens are excluded from the output. Defaults to `1`.
    - **type: lowercase** (`type: lowercase`)
      - `type` (enum) — required
        Values: `lowercase`
      - `version` (string) — optional
      - `language` (enum) — optional
        Language-specific lowercase token filter to use.
        Values: `greek`, `irish`, `turkish`
    - **type: min_hash** (`type: min_hash`)
      - `type` (enum) — required
        Values: `min_hash`
      - `version` (string) — optional
      - `bucket_count` (number) — optional
        Number of buckets to which hashes are assigned. Defaults to `512`.
      - `hash_count` (number) — optional
        Number of ways to hash each token in the stream. Defaults to `1`.
      - `hash_set_size` (number) — optional
        Number of hashes to keep from each bucket. Defaults to `1`.
Hashes are retained by ascending size, starting with the bucket’s smallest hash first.
      - `with_rotation` (boolean) — optional
        If `true`, the filter fills empty buckets with the value of the first non-empty bucket to its circular right if the `hash_set_size` is `1`. If the `bucket_count` argument is greater than 1, this parameter defaults to `true`. Otherwise, this parameter defaults to `false`.
    - **type: multiplexer** (`type: multiplexer`)
      - `type` (enum) — required
        Values: `multiplexer`
      - `version` (string) — optional
      - `filters` (string[]) — required
        A list of token filters to apply to incoming tokens.
      - `preserve_original` (boolean | string) — optional
        If `true` (the default) then emit the original token in addition to the filtered tokens.
    - **type: ngram** (`type: ngram`)
      - `type` (enum) — required
        Values: `ngram`
      - `version` (string) — optional
      - `max_gram` (number) — optional
        Maximum length of characters in a gram. Defaults to `2`.
      - `min_gram` (number) — optional
        Minimum length of characters in a gram. Defaults to `1`.
      - `preserve_original` (boolean | string) — optional
        Emits original token when set to `true`. Defaults to `false`.
    - **type: nori_part_of_speech** (`type: nori_part_of_speech`)
      - `type` (enum) — required
        Values: `nori_part_of_speech`
      - `version` (string) — optional
      - `stoptags` (string[]) — optional
        An array of part-of-speech tags that should be removed.
    - **type: pattern_capture** (`type: pattern_capture`)
      - `type` (enum) — required
        Values: `pattern_capture`
      - `version` (string) — optional
      - `patterns` (string[]) — required
        A list of regular expressions to match.
      - `preserve_original` (boolean | string) — optional
        If set to `true` (the default) it will emit the original token.
    - **type: pattern_replace** (`type: pattern_replace`)
      - `type` (enum) — required
        Values: `pattern_replace`
      - `version` (string) — optional
      - `all` (boolean) — optional
        If `true`, all substrings matching the pattern parameter’s regular expression are replaced. If `false`, the filter replaces only the first matching substring in each token. Defaults to `true`.
      - `flags` (string) — optional
      - `pattern` (string) — required
        Regular expression, written in Java’s regular expression syntax. The filter replaces token substrings matching this pattern with the substring in the `replacement` parameter.
      - `replacement` (string) — optional
        Replacement substring. Defaults to an empty substring (`""`).
    - **type: persian_normalization** (`type: persian_normalization`)
      - `type` (enum) — required
        Values: `persian_normalization`
      - `version` (string) — optional
    - **type: persian_stem** (`type: persian_stem`)
      - `type` (enum) — required
        Values: `persian_stem`
      - `version` (string) — optional
    - **type: porter_stem** (`type: porter_stem`)
      - `type` (enum) — required
        Values: `porter_stem`
      - `version` (string) — optional
    - **type: predicate_token_filter** (`type: predicate_token_filter`)
      - `type` (enum) — required
        Values: `predicate_token_filter`
      - `version` (string) — optional
      - `script` (string) — required
        Script containing a condition used to filter incoming tokens. Only tokens that match this script are included in the output.
    - **type: remove_duplicates** (`type: remove_duplicates`)
      - `type` (enum) — required
        Values: `remove_duplicates`
      - `version` (string) — optional
    - **type: reverse** (`type: reverse`)
      - `type` (enum) — required
        Values: `reverse`
      - `version` (string) — optional
    - **type: russian_stem** (`type: russian_stem`)
      - `type` (enum) — required
        Values: `russian_stem`
      - `version` (string) — optional
    - **type: scandinavian_folding** (`type: scandinavian_folding`)
      - `type` (enum) — required
        Values: `scandinavian_folding`
      - `version` (string) — optional
    - **type: scandinavian_normalization** (`type: scandinavian_normalization`)
      - `type` (enum) — required
        Values: `scandinavian_normalization`
      - `version` (string) — optional
    - **type: serbian_normalization** (`type: serbian_normalization`)
      - `type` (enum) — required
        Values: `serbian_normalization`
      - `version` (string) — optional
    - **type: shingle** (`type: shingle`)
      - `type` (enum) — required
        Values: `shingle`
      - `version` (string) — optional
      - `filler_token` (string) — optional
        String used in shingles as a replacement for empty positions that do not contain a token. This filler token is only used in shingles, not original unigrams. Defaults to an underscore (`_`).
      - `max_shingle_size` (number | string) — optional
        Maximum number of tokens to concatenate when creating shingles. Defaults to `2`.
      - `min_shingle_size` (number | string) — optional
        Minimum number of tokens to concatenate when creating shingles. Defaults to `2`.
      - `output_unigrams` (boolean) — optional
        If `true`, the output includes the original input tokens. If `false`, the output only includes shingles; the original input tokens are removed. Defaults to `true`.
      - `output_unigrams_if_no_shingles` (boolean) — optional
        If `true`, the output includes the original input tokens only if no shingles are produced; if shingles are produced, the output only includes shingles. Defaults to `false`.
      - `token_separator` (string) — optional
        Separator used to concatenate adjacent tokens to form a shingle. Defaults to a space (`" "`).
    - **type: snowball** (`type: snowball`)
      - `type` (enum) — required
        Values: `snowball`
      - `version` (string) — optional
      - `language` (enum) — optional
        Controls the language used by the stemmer.
        Values: `Arabic`, `Armenian`, `Basque`, `Catalan`, `Danish`, `Dutch`, `English`, `Estonian`, `Finnish`, `French`, `German`, `German2`, `Hungarian`, `Italian`, `Irish`, `Kp`, `Lithuanian`, `Lovins`, `Norwegian`, `Porter`, `Portuguese`, `Romanian`, `Russian`, `Serbian`, `Spanish`, `Swedish`, `Turkish`
    - **type: sorani_normalization** (`type: sorani_normalization`)
      - `type` (enum) — required
        Values: `sorani_normalization`
      - `version` (string) — optional
    - **type: stemmer_override** (`type: stemmer_override`)
      - `type` (enum) — required
        Values: `stemmer_override`
      - `version` (string) — optional
      - `rules` (string[]) — optional
        A list of mapping rules to use.
      - `rules_path` (string) — optional
        A path (either relative to `config` location, or absolute) to a list of mappings.
    - **type: stemmer** (`type: stemmer`)
      - `type` (enum) — required
        Values: `stemmer`
      - `version` (string) — optional
      - `language` (string) — optional
    - **type: stop** (`type: stop`)
      - `type` (enum) — required
        Values: `stop`
      - `version` (string) — optional
      - `ignore_case` (boolean) — optional
        If `true`, stop word matching is case insensitive. For example, if `true`, a stop word of the matches and removes `The`, `THE`, or `the`. Defaults to `false`.
      - `remove_trailing` (boolean) — optional
        If `true`, the last token of a stream is removed if it’s a stop word. Defaults to `true`.
      - `stopwords` (union oneOf) — optional
        Language value, such as `_arabic_` or `_thai_`. Defaults to `_english_`.
        Values: `_arabic_`, `_armenian_`, `_basque_`, `_bengali_`, `_brazilian_`, `_bulgarian_`, `_catalan_`, `_cjk_`, `_czech_`, `_danish_`, `_dutch_`, `_english_`, `_estonian_`, `_finnish_`, `_french_`, `_galician_`, `_german_`, `_greek_`, `_hindi_`, `_hungarian_`, `_indonesian_`, `_irish_`, `_italian_`, `_latvian_`, `_lithuanian_`, `_norwegian_`, `_persian_`, `_portuguese_`, `_romanian_`, `_russian_`, `_serbian_`, `_sorani_`, `_spanish_`, `_swedish_`, `_thai_`, `_turkish_`, `_none_`
      - `stopwords_path` (string) — optional
        Path to a file that contains a list of stop words to remove.
This path must be absolute or relative to the `config` location, and the file must be UTF-8 encoded. Each stop word in the file must be separated by a line break.
    - **type: synonym_graph** (`type: synonym_graph`)
      - `type` (enum) — required
        Values: `synonym_graph`
      - `version` (string) — optional
      - `expand` (boolean) — optional
        Expands definitions for equivalent synonym rules. Defaults to `true`.
      - `format` (enum) — optional
        Sets the synonym rules format.
        Values: `solr`, `wordnet`
      - `lenient` (boolean) — optional
        If `true` ignores errors while parsing the synonym rules. It is important to note that only those synonym rules which cannot get parsed are ignored. Defaults to the value of the `updateable` setting.
      - `synonyms` (string[]) — optional
        Used to define inline synonyms.
      - `synonyms_path` (string) — optional
        Used to provide a synonym file. This path must be absolute or relative to the `config` location.
      - `synonyms_set` (union string | string[]) — optional
        Provide one or more synonym sets created through the Synonyms Management APIs. Maximum 100 sets per filter.
      - `tokenizer` (string) — optional — deprecated
        Controls the tokenizers that will be used to tokenize the synonym, this parameter is for backwards compatibility for indices that created before 6.0.
      - `updateable` (boolean) — optional
        If `true` allows reloading search analyzers to pick up changes to synonym files. Only to be used for search analyzers. Defaults to `false`.
    - **type: synonym** (`type: synonym`)
      - `type` (enum) — required
        Values: `synonym`
      - `version` (string) — optional
      - `expand` (boolean) — optional
        Expands definitions for equivalent synonym rules. Defaults to `true`.
      - `format` (enum) — optional
        Sets the synonym rules format.
        Values: `solr`, `wordnet`
      - `lenient` (boolean) — optional
        If `true` ignores errors while parsing the synonym rules. It is important to note that only those synonym rules which cannot get parsed are ignored. Defaults to the value of the `updateable` setting.
      - `synonyms` (string[]) — optional
        Used to define inline synonyms.
      - `synonyms_path` (string) — optional
        Used to provide a synonym file. This path must be absolute or relative to the `config` location.
      - `synonyms_set` (union string | string[]) — optional
        Provide one or more synonym sets created through the Synonyms Management APIs. Maximum 100 sets per filter.
      - `tokenizer` (string) — optional — deprecated
        Controls the tokenizers that will be used to tokenize the synonym, this parameter is for backwards compatibility for indices that created before 6.0.
      - `updateable` (boolean) — optional
        If `true` allows reloading search analyzers to pick up changes to synonym files. Only to be used for search analyzers. Defaults to `false`.
    - **type: trim** (`type: trim`)
      - `type` (enum) — required
        Values: `trim`
      - `version` (string) — optional
    - **type: truncate** (`type: truncate`)
      - `type` (enum) — required
        Values: `truncate`
      - `version` (string) — optional
      - `length` (number) — optional
        Character limit for each token. Tokens exceeding this limit are truncated. Defaults to `10`.
    - **type: unique** (`type: unique`)
      - `type` (enum) — required
        Values: `unique`
      - `version` (string) — optional
      - `only_on_same_position` (boolean) — optional
        If `true`, only remove duplicate tokens in the same position. Defaults to `false`.
    - **type: uppercase** (`type: uppercase`)
      - `type` (enum) — required
        Values: `uppercase`
      - `version` (string) — optional
    - **type: word_delimiter_graph** (`type: word_delimiter_graph`)
      - `type` (enum) — required
        Values: `word_delimiter_graph`
      - `version` (string) — optional
      - `catenate_all` (boolean) — optional
        If `true`, the filter produces catenated tokens for chains of alphanumeric characters separated by non-alphabetic delimiters. Defaults to `false`.
      - `catenate_numbers` (boolean) — optional
        If `true`, the filter produces catenated tokens for chains of numeric characters separated by non-alphabetic delimiters. Defaults to `false`.
      - `catenate_words` (boolean) — optional
        If `true`, the filter produces catenated tokens for chains of alphabetical characters separated by non-alphabetic delimiters. Defaults to `false`.
      - `generate_number_parts` (boolean) — optional
        If `true`, the filter includes tokens consisting of only numeric characters in the output. If `false`, the filter excludes these tokens from the output. Defaults to `true`.
      - `generate_word_parts` (boolean) — optional
        If `true`, the filter includes tokens consisting of only alphabetical characters in the output. If `false`, the filter excludes these tokens from the output. Defaults to `true`.
      - `preserve_original` (boolean | string) — optional
        If `true`, the filter includes the original version of any split tokens in the output. This original version includes non-alphanumeric delimiters. Defaults to `false`.
      - `protected_words` (string[]) — optional
        Array of tokens the filter won’t split.
      - `protected_words_path` (string) — optional
        Path to a file that contains a list of tokens the filter won’t split.
This path must be absolute or relative to the `config` location, and the file must be UTF-8 encoded. Each token in the file must be separated by a line break.
      - `split_on_case_change` (boolean) — optional
        If `true`, the filter splits tokens at letter case transitions. For example: camelCase -> [ camel, Case ]. Defaults to `true`.
      - `split_on_numerics` (boolean) — optional
        If `true`, the filter splits tokens at letter-number transitions. For example: j2se -> [ j, 2, se ]. Defaults to `true`.
      - `stem_english_possessive` (boolean) — optional
        If `true`, the filter removes the English possessive (`'s`) from the end of each token. For example: O'Neil's -> [ O, Neil ]. Defaults to `true`.
      - `type_table` (string[]) — optional
        Array of custom type mappings for characters. This allows you to map non-alphanumeric characters as numeric or alphanumeric to avoid splitting on those characters.
      - `type_table_path` (string) — optional
        Path to a file that contains custom type mappings for characters. This allows you to map non-alphanumeric characters as numeric or alphanumeric to avoid splitting on those characters.
      - `adjust_offsets` (boolean) — optional
        If `true`, the filter adjusts the offsets of split or catenated tokens to better reflect their actual position in the token stream. Defaults to `true`.
      - `ignore_keywords` (boolean) — optional
        If `true`, the filter skips tokens with a keyword attribute of true. Defaults to `false`.
    - **type: word_delimiter** (`type: word_delimiter`)
      - `type` (enum) — required
        Values: `word_delimiter`
      - `version` (string) — optional
      - `catenate_all` (boolean) — optional
        If `true`, the filter produces catenated tokens for chains of alphanumeric characters separated by non-alphabetic delimiters. Defaults to `false`.
      - `catenate_numbers` (boolean) — optional
        If `true`, the filter produces catenated tokens for chains of numeric characters separated by non-alphabetic delimiters. Defaults to `false`.
      - `catenate_words` (boolean) — optional
        If `true`, the filter produces catenated tokens for chains of alphabetical characters separated by non-alphabetic delimiters. Defaults to `false`.
      - `generate_number_parts` (boolean) — optional
        If `true`, the filter includes tokens consisting of only numeric characters in the output. If `false`, the filter excludes these tokens from the output. Defaults to `true`.
      - `generate_word_parts` (boolean) — optional
        If `true`, the filter includes tokens consisting of only alphabetical characters in the output. If `false`, the filter excludes these tokens from the output. Defaults to `true`.
      - `preserve_original` (boolean | string) — optional
        If `true`, the filter includes the original version of any split tokens in the output. This original version includes non-alphanumeric delimiters. Defaults to `false`.
      - `protected_words` (string[]) — optional
        Array of tokens the filter won’t split.
      - `protected_words_path` (string) — optional
        Path to a file that contains a list of tokens the filter won’t split.
This path must be absolute or relative to the `config` location, and the file must be UTF-8 encoded. Each token in the file must be separated by a line break.
      - `split_on_case_change` (boolean) — optional
        If `true`, the filter splits tokens at letter case transitions. For example: camelCase -> [ camel, Case ]. Defaults to `true`.
      - `split_on_numerics` (boolean) — optional
        If `true`, the filter splits tokens at letter-number transitions. For example: j2se -> [ j, 2, se ]. Defaults to `true`.
      - `stem_english_possessive` (boolean) — optional
        If `true`, the filter removes the English possessive (`'s`) from the end of each token. For example: O'Neil's -> [ O, Neil ]. Defaults to `true`.
      - `type_table` (string[]) — optional
        Array of custom type mappings for characters. This allows you to map non-alphanumeric characters as numeric or alphanumeric to avoid splitting on those characters.
      - `type_table_path` (string) — optional
        Path to a file that contains custom type mappings for characters. This allows you to map non-alphanumeric characters as numeric or alphanumeric to avoid splitting on those characters.
    - **type: ja_stop** (`type: ja_stop`)
      - `type` (enum) — required
        Values: `ja_stop`
      - `version` (string) — optional
      - `stopwords` (union oneOf) — optional
        Values: `_arabic_`, `_armenian_`, `_basque_`, `_bengali_`, `_brazilian_`, `_bulgarian_`, `_catalan_`, `_cjk_`, `_czech_`, `_danish_`, `_dutch_`, `_english_`, `_estonian_`, `_finnish_`, `_french_`, `_galician_`, `_german_`, `_greek_`, `_hindi_`, `_hungarian_`, `_indonesian_`, `_irish_`, `_italian_`, `_latvian_`, `_lithuanian_`, `_norwegian_`, `_persian_`, `_portuguese_`, `_romanian_`, `_russian_`, `_serbian_`, `_sorani_`, `_spanish_`, `_swedish_`, `_thai_`, `_turkish_`, `_none_`
    - **type: kuromoji_stemmer** (`type: kuromoji_stemmer`)
      - `type` (enum) — required
        Values: `kuromoji_stemmer`
      - `version` (string) — optional
      - `minimum_length` (number) — required
    - **type: kuromoji_readingform** (`type: kuromoji_readingform`)
      - `type` (enum) — required
        Values: `kuromoji_readingform`
      - `version` (string) — optional
      - `use_romaji` (boolean) — required
    - **type: kuromoji_part_of_speech** (`type: kuromoji_part_of_speech`)
      - `type` (enum) — required
        Values: `kuromoji_part_of_speech`
      - `version` (string) — optional
      - `stoptags` (string[]) — required
    - **type: icu_collation** (`type: icu_collation`)
      - `type` (enum) — required
        Values: `icu_collation`
      - `version` (string) — optional
      - `alternate` (enum) — optional
        Values: `shifted`, `non-ignorable`
      - `caseFirst` (enum) — optional
        Values: `lower`, `upper`
      - `caseLevel` (boolean) — optional
      - `country` (string) — optional
      - `decomposition` (enum) — optional
        Values: `no`, `identical`
      - `hiraganaQuaternaryMode` (boolean) — optional
      - `language` (string) — optional
      - `numeric` (boolean) — optional
      - `rules` (string) — optional
      - `strength` (enum) — optional
        Values: `primary`, `secondary`, `tertiary`, `quaternary`, `identical`
      - `variableTop` (string) — optional
      - `variant` (string) — optional
    - **type: icu_folding** (`type: icu_folding`)
      - `type` (enum) — required
        Values: `icu_folding`
      - `version` (string) — optional
      - `unicode_set_filter` (string) — required
    - **type: icu_normalizer** (`type: icu_normalizer`)
      - `type` (enum) — required
        Values: `icu_normalizer`
      - `version` (string) — optional
      - `name` (enum) — required
        Values: `nfc`, `nfkc`, `nfkc_cf`
    - **type: icu_transform** (`type: icu_transform`)
      - `type` (enum) — required
        Values: `icu_transform`
      - `version` (string) — optional
      - `dir` (enum) — optional
        Values: `forward`, `reverse`
      - `id` (string) — required
    - **type: phonetic** (`type: phonetic`)
      - `type` (enum) — required
        Values: `phonetic`
      - `version` (string) — optional
      - `encoder` (enum) — required
        Values: `metaphone`, `double_metaphone`, `soundex`, `refined_soundex`, `caverphone1`, `caverphone2`, `cologne`, `nysiis`, `koelnerphonetik`, `haasephonetik`, `beider_morse`, `daitch_mokotoff`
      - `languageset` (union enum | enum[]) — optional
        

Supported values include: `any`, `common`, `cyrillic`, `english`, `french`, `german`, `hebrew`, `hungarian`, `polish`, `romanian`, `russian`, `spanish`
        Values: `any`, `common`, `cyrillic`, `english`, `french`, `german`, `hebrew`, `hungarian`, `polish`, `romanian`, `russian`, `spanish`
      - `max_code_len` (number) — optional
      - `name_type` (enum) — optional
        Values: `generic`, `ashkenazi`, `sephardic`
      - `replace` (boolean) — optional
      - `rule_type` (enum) — optional
        Values: `approx`, `exact`
    - **type: dictionary_decompounder** (`type: dictionary_decompounder`)
      - `type` (enum) — required
        Values: `dictionary_decompounder`
      - `version` (string) — optional
      - `max_subword_size` (number) — optional
        Maximum subword character length. Longer subword tokens are excluded from the output. Defaults to `15`.
      - `min_subword_size` (number) — optional
        Minimum subword character length. Shorter subword tokens are excluded from the output. Defaults to `2`.
      - `min_word_size` (number) — optional
        Minimum word character length. Shorter word tokens are excluded from the output. Defaults to `5`.
      - `only_longest_match` (boolean) — optional
        If `true`, only include the longest matching subword. Defaults to `false`.
      - `word_list` (string[]) — optional
        A list of subwords to look for in the token stream. If found, the subword is included in the token output.
Either this parameter or `word_list_path` must be specified.
      - `word_list_path` (string) — optional
        Path to a file that contains a list of subwords to find in the token stream. If found, the subword is included in the token output.
This path must be absolute or relative to the config location, and the file must be UTF-8 encoded. Each token in the file must be separated by a line break.
Either this parameter or `word_list` must be specified.
- `normalizer` (string) — optional
  Normalizer to use to convert text into a single token.
- `text` (union oneOf) — optional
  Text to analyze.
If an array of strings is provided, it is analyzed as a multi-value field.
  One of: `string[]` or `string`
- `tokenizer` (union oneOf) — optional
  Tokenizer to use to convert text into tokens.
  - **string**
  - **TokenizerDefinition**
    One of:
    - **type: char_group** (`type: char_group`)
      - `type` (enum) — required
        Values: `char_group`
      - `version` (string) — optional
      - `tokenize_on_chars` (string[]) — required
      - `max_token_length` (number) — optional
    - **type: classic** (`type: classic`)
      - `type` (enum) — required
        Values: `classic`
      - `version` (string) — optional
      - `max_token_length` (number) — optional
    - **type: edge_ngram** (`type: edge_ngram`)
      - `type` (enum) — required
        Values: `edge_ngram`
      - `version` (string) — optional
      - `custom_token_chars` (string) — optional
      - `max_gram` (number) — optional
      - `min_gram` (number) — optional
      - `token_chars` (enum[] · default: []) — optional
        Values: `letter`, `digit`, `whitespace`, `punctuation`, `symbol`, `custom`
    - **type: keyword** (`type: keyword`)
      - `type` (enum) — required
        Values: `keyword`
      - `version` (string) — optional
      - `buffer_size` (number · default: 256) — optional
    - **type: letter** (`type: letter`)
      - `type` (enum) — required
        Values: `letter`
      - `version` (string) — optional
    - **type: lowercase** (`type: lowercase`)
      - `type` (enum) — required
        Values: `lowercase`
      - `version` (string) — optional
    - **type: ngram** (`type: ngram`)
      - `type` (enum) — required
        Values: `ngram`
      - `version` (string) — optional
      - `custom_token_chars` (string) — optional
      - `max_gram` (number) — optional
      - `min_gram` (number) — optional
      - `token_chars` (enum[] · default: []) — optional
        Values: `letter`, `digit`, `whitespace`, `punctuation`, `symbol`, `custom`
    - **type: path_hierarchy** (`type: path_hierarchy`)
      - `type` (enum) — required
        Values: `path_hierarchy`
      - `version` (string) — optional
      - `buffer_size` (number | string) — optional
      - `delimiter` (string) — optional
      - `replacement` (string) — optional
      - `reverse` (boolean | string) — optional
      - `skip` (number | string) — optional
    - **type: pattern** (`type: pattern`)
      - `type` (enum) — required
        Values: `pattern`
      - `version` (string) — optional
      - `flags` (string) — optional
      - `group` (number) — optional
      - `pattern` (string) — optional
    - **type: simple_pattern** (`type: simple_pattern`)
      - `type` (enum) — required
        Values: `simple_pattern`
      - `version` (string) — optional
      - `pattern` (string) — optional
    - **type: simple_pattern_split** (`type: simple_pattern_split`)
      - `type` (enum) — required
        Values: `simple_pattern_split`
      - `version` (string) — optional
      - `pattern` (string) — optional
    - **type: standard** (`type: standard`)
      - `type` (enum) — required
        Values: `standard`
      - `version` (string) — optional
      - `max_token_length` (number) — optional
    - **type: thai** (`type: thai`)
      - `type` (enum) — required
        Values: `thai`
      - `version` (string) — optional
    - **type: uax_url_email** (`type: uax_url_email`)
      - `type` (enum) — required
        Values: `uax_url_email`
      - `version` (string) — optional
      - `max_token_length` (number) — optional
    - **type: whitespace** (`type: whitespace`)
      - `type` (enum) — required
        Values: `whitespace`
      - `version` (string) — optional
      - `max_token_length` (number) — optional
    - **type: icu_tokenizer** (`type: icu_tokenizer`)
      - `type` (enum) — required
        Values: `icu_tokenizer`
      - `version` (string) — optional
      - `rule_files` (string) — required
    - **type: kuromoji_tokenizer** (`type: kuromoji_tokenizer`)
      - `type` (enum) — required
        Values: `kuromoji_tokenizer`
      - `version` (string) — optional
      - `discard_punctuation` (boolean) — optional
      - `mode` (enum) — required
        Values: `normal`, `search`, `extended`
      - `nbest_cost` (number) — optional
      - `nbest_examples` (string) — optional
      - `user_dictionary` (string) — optional
      - `user_dictionary_rules` (string[]) — optional
      - `discard_compound_token` (boolean) — optional
    - **type: nori_tokenizer** (`type: nori_tokenizer`)
      - `type` (enum) — required
        Values: `nori_tokenizer`
      - `version` (string) — optional
      - `decompound_mode` (enum) — optional
        Values: `discard`, `none`, `mixed`
      - `discard_punctuation` (boolean) — optional
      - `user_dictionary` (string) — optional
      - `user_dictionary_rules` (string[]) — optional

## Response

`application/json`

- `detail` (object)
  - `analyzer` (object)
    - `name` (string)
    - `tokens` (object[])
      - `bytes` (string)
      - `end_offset` (number)
      - `keyword` (boolean)
      - `position` (number)
      - `positionLength` (number)
      - `start_offset` (number)
      - `termFrequency` (number)
      - `token` (string)
      - `type` (string)
  - `charfilters` (object[])
    - `filtered_text` (string[])
    - `name` (string)
  - `custom_analyzer` (boolean)
  - `tokenfilters` (object[])
    - `name` (string)
    - `tokens` (object[])
      - `bytes` (string)
      - `end_offset` (number)
      - `keyword` (boolean)
      - `position` (number)
      - `positionLength` (number)
      - `start_offset` (number)
      - `termFrequency` (number)
      - `token` (string)
      - `type` (string)
  - `tokenizer` (object)
    Same fields as `tokenfilters` in `detail`
- `tokens` (object[])
  - `end_offset` (number)
  - `position` (number)
  - `positionLength` (number)
  - `start_offset` (number)
  - `token` (string)
  - `type` (string)
## Code examples

### No index specified

#### Console

```console
POST /_analyze
{
  "analyzer": "standard",
  "text": "this is a test"
}
```

#### JavaScript

```javascript
const response = await client.indices.analyze({
  analyzer: "standard",
  text: "this is a test",
});
```

#### Python

```python
resp = client.indices.analyze(
    analyzer="standard",
    text="this is a test",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_analyze" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "analyzer": "standard",
    "text": "this is a test"
  }'
```

#### Java

```java
client.indices().analyze(a -> a
    .analyzer("standard")
    .text("this is a test")
);
```

#### C#

```c#
var response = await client.Indices
    .AnalyzeAsync(d1 => d1
        .Analyzer("standard")
        .Text("this is a test")
    );
```

#### PHP

```php
$resp = $client->indices()->analyze([
    "body" => [
        "analyzer" => "standard",
        "text" => "this is a test",
    ],
]);
```

#### Ruby

```ruby
response = client.indices.analyze(
  body: {
    "analyzer": "standard",
    "text": "this is a test"
  }
)
```

### An array of text strings

#### Console

```console
POST /_analyze
{
  "analyzer": "standard",
  "text": [
    "this is a test",
    "the second text"
  ]
}
```

#### JavaScript

```javascript
const response = await client.indices.analyze({
  analyzer: "standard",
  text: ["this is a test", "the second text"],
});
```

#### Python

```python
resp = client.indices.analyze(
    analyzer="standard",
    text=[
        "this is a test",
        "the second text"
    ],
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_analyze" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "analyzer": "standard",
    "text": [
      "this is a test",
      "the second text"
    ]
  }'
```

#### Java

```java
client.indices().analyze(a -> a
    .analyzer("standard")
    .text(List.of("this is a test","the second text"))
);
```

#### C#

```c#
var response = await client.Indices
    .AnalyzeAsync(d1 => d1
        .Analyzer("standard")
        .Text("this is a test", "the second text")
    );
```

#### PHP

```php
$resp = $client->indices()->analyze([
    "body" => [
        "analyzer" => "standard",
        "text" => array(
            "this is a test",
            "the second text",
        ),
    ],
]);
```

#### Ruby

```ruby
response = client.indices.analyze(
  body: {
    "analyzer": "standard",
    "text": [
      "this is a test",
      "the second text"
    ]
  }
)
```

### Custom analyzer example 1

#### Console

```console
POST /_analyze
{
  "tokenizer": "keyword",
  "filter": [
    "lowercase"
  ],
  "char_filter": [
    "html_strip"
  ],
  "text": "this is a <b>test</b>"
}
```

#### JavaScript

```javascript
const response = await client.indices.analyze({
  tokenizer: "keyword",
  filter: ["lowercase"],
  char_filter: ["html_strip"],
  text: "this is a test</b>",
});
```

#### Python

```python
resp = client.indices.analyze(
    tokenizer="keyword",
    filter=[
        "lowercase"
    ],
    char_filter=[
        "html_strip"
    ],
    text="this is a test</b>",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_analyze" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tokenizer": "keyword",
    "filter": [
      "lowercase"
    ],
    "char_filter": [
      "html_strip"
    ],
    "text": "this is a test\u003C/b\u003E"
  }'
```

#### Java

```java
client.indices().analyze(a -> a
    .charFilter(c -> c
        .name("html_strip")
    )
    .filter(f -> f
        .name("lowercase")
    )
    .text("this is a test</b>")
    .tokenizer(t -> t
        .name("keyword")
    )
);
```

#### PHP

```php
$resp = $client->indices()->analyze([
    "body" => [
        "tokenizer" => "keyword",
        "filter" => array(
            "lowercase",
        ),
        "char_filter" => array(
            "html_strip",
        ),
        "text" => "this is a test</b>",
    ],
]);
```

#### Ruby

```ruby
response = client.indices.analyze(
  body: {
    "tokenizer": "keyword",
    "filter": [
      "lowercase"
    ],
    "char_filter": [
      "html_strip"
    ],
    "text": "this is a test</b>"
  }
)
```

### Custom analyzer example 2

#### Console

```console
POST /_analyze
{
  "tokenizer": "whitespace",
  "filter": [
    "lowercase",
    {
      "type": "stop",
      "stopwords": [
        "a",
        "is",
        "this"
      ]
    }
  ],
  "text": "this is a test"
}
```

#### JavaScript

```javascript
const response = await client.indices.analyze({
  tokenizer: "whitespace",
  filter: [
    "lowercase",
    {
      type: "stop",
      stopwords: ["a", "is", "this"],
    },
  ],
  text: "this is a test",
});
```

#### Python

```python
resp = client.indices.analyze(
    tokenizer="whitespace",
    filter=[
        "lowercase",
        {
            "type": "stop",
            "stopwords": [
                "a",
                "is",
                "this"
            ]
        }
    ],
    text="this is a test",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_analyze" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tokenizer": "whitespace",
    "filter": [
      "lowercase",
      {
        "type": "stop",
        "stopwords": [
          "a",
          "is",
          "this"
        ]
      }
    ],
    "text": "this is a test"
  }'
```

#### Java

```java
client.indices().analyze(a -> a
    .filter(List.of(TokenFilter.of(t -> t
            .name("lowercase")
        ),TokenFilter.of(to -> to
            .definition(d -> d
                .stop(s -> s
                    .stopwords(List.of("a","is","this"))
                )
            )
        )))
    .text("this is a test")
    .tokenizer(tok -> tok
        .name("whitespace")
    )
);
```

#### PHP

```php
$resp = $client->indices()->analyze([
    "body" => [
        "tokenizer" => "whitespace",
        "filter" => array(
            "lowercase",
            [
                "type" => "stop",
                "stopwords" => array(
                    "a",
                    "is",
                    "this",
                ),
            ],
        ),
        "text" => "this is a test",
    ],
]);
```

#### Ruby

```ruby
response = client.indices.analyze(
  body: {
    "tokenizer": "whitespace",
    "filter": [
      "lowercase",
      {
        "type": "stop",
        "stopwords": [
          "a",
          "is",
          "this"
        ]
      }
    ],
    "text": "this is a test"
  }
)
```

### Derive analyzer from field mapping

#### Console

```console
POST /analyze_sample/_analyze
{
  "field": "obj1.field1",
  "text": "this is a test"
}
```

#### JavaScript

```javascript
const response = await client.indices.analyze({
  index: "analyze_sample",
  field: "obj1.field1",
  text: "this is a test",
});
```

#### Python

```python
resp = client.indices.analyze(
    index="analyze_sample",
    field="obj1.field1",
    text="this is a test",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/analyze_sample/_analyze" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "field": "obj1.field1",
    "text": "this is a test"
  }'
```

#### Java

```java
client.indices().analyze(a -> a
    .field("obj1.field1")
    .index("analyze_sample")
    .text("this is a test")
);
```

#### C#

```c#
var response = await client.Indices
    .AnalyzeAsync(d1 => d1
        .Index("analyze_sample")
        .Field(x => x.Obj1.Field1)
        .Text("this is a test")
    );
```

#### PHP

```php
$resp = $client->indices()->analyze([
    "index" => "analyze_sample",
    "body" => [
        "field" => "obj1.field1",
        "text" => "this is a test",
    ],
]);
```

#### Ruby

```ruby
response = client.indices.analyze(
  index: "analyze_sample",
  body: {
    "field": "obj1.field1",
    "text": "this is a test"
  }
)
```

### Normalizer

#### Console

```console
POST /analyze_sample/_analyze
{
  "normalizer": "my_normalizer",
  "text": "BaR"
}
```

#### JavaScript

```javascript
const response = await client.indices.analyze({
  index: "analyze_sample",
  normalizer: "my_normalizer",
  text: "BaR",
});
```

#### Python

```python
resp = client.indices.analyze(
    index="analyze_sample",
    normalizer="my_normalizer",
    text="BaR",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/analyze_sample/_analyze" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "normalizer": "my_normalizer",
    "text": "BaR"
  }'
```

#### Java

```java
client.indices().analyze(a -> a
    .index("analyze_sample")
    .normalizer("my_normalizer")
    .text("BaR")
);
```

#### C#

```c#
var response = await client.Indices
    .AnalyzeAsync(d1 => d1
        .Index("analyze_sample")
        .Normalizer("my_normalizer")
        .Text("BaR")
    );
```

#### PHP

```php
$resp = $client->indices()->analyze([
    "index" => "analyze_sample",
    "body" => [
        "normalizer" => "my_normalizer",
        "text" => "BaR",
    ],
]);
```

#### Ruby

```ruby
response = client.indices.analyze(
  index: "analyze_sample",
  body: {
    "normalizer": "my_normalizer",
    "text": "BaR"
  }
)
```

### Explain analysis

#### Console

```console
POST /_analyze
{
  "tokenizer": "standard",
  "filter": [
    "snowball"
  ],
  "text": "detailed output",
  "explain": true,
  "attributes": [
    "keyword"
  ]
}
```

#### JavaScript

```javascript
const response = await client.indices.analyze({
  tokenizer: "standard",
  filter: ["snowball"],
  text: "detailed output",
  explain: true,
  attributes: ["keyword"],
});
```

#### Python

```python
resp = client.indices.analyze(
    tokenizer="standard",
    filter=[
        "snowball"
    ],
    text="detailed output",
    explain=True,
    attributes=[
        "keyword"
    ],
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_analyze" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tokenizer": "standard",
    "filter": [
      "snowball"
    ],
    "text": "detailed output",
    "explain": true,
    "attributes": [
      "keyword"
    ]
  }'
```

#### Java

```java
client.indices().analyze(a -> a
    .attributes("keyword")
    .explain(true)
    .filter(f -> f
        .name("snowball")
    )
    .text("detailed output")
    .tokenizer(t -> t
        .name("standard")
    )
);
```

#### PHP

```php
$resp = $client->indices()->analyze([
    "body" => [
        "tokenizer" => "standard",
        "filter" => array(
            "snowball",
        ),
        "text" => "detailed output",
        "explain" => true,
        "attributes" => array(
            "keyword",
        ),
    ],
]);
```

#### Ruby

```ruby
response = client.indices.analyze(
  body: {
    "tokenizer": "standard",
    "filter": [
      "snowball"
    ],
    "text": "detailed output",
    "explain": true,
    "attributes": [
      "keyword"
    ]
  }
)
```

## Response examples

#### Indices analyze response example7

`application/json`

A successful response for an analysis with `explain` set to `true`.

```json
{
  "detail": {
    "custom_analyzer": true,
    "charfilters": [],
    "tokenizer": {
      "name": "standard",
      "tokens": [
        {
          "token": "detailed",
          "start_offset": 0,
          "end_offset": 8,
          "type": "<ALPHANUM>",
          "position": 0
        },
        {
          "token": "output",
          "start_offset": 9,
          "end_offset": 15,
          "type": "<ALPHANUM>",
          "position": 1
        }
      ]
    },
    "tokenfilters": [
      {
        "name": "snowball",
        "tokens": [
          {
            "token": "detail",
            "start_offset": 0,
            "end_offset": 8,
            "type": "<ALPHANUM>",
            "position": 0,
            "keyword": false
          },
          {
            "token": "output",
            "start_offset": 9,
            "end_offset": 15,
            "type": "<ALPHANUM>",
            "position": 1,
            "keyword": false
          }
        ]
      }
    ]
  }
}
```

