All Products
Search
Document Center

Elasticsearch:Use the IK analyzer plugin (analysis-ik)

Last Updated:Jul 15, 2026

The IK analyzer plugin (analysis-ik) provides Chinese text tokenization for Alibaba Cloud Elasticsearch with multiple built-in dictionary types. You can customize or extend dictionaries to improve tokenization accuracy and dynamically load dictionary files from Object Storage Service (OSS) for remote management.

Background information

The IK analyzer plugin consists of three components: tokenizers, dictionary files, and update mechanisms.

Important

The IK analyzer plugin version must match the Elasticsearch cluster version. For example, if your cluster runs version 8.17, the IK analyzer plugin is also version 8.17.

  • Tokenizers: Split Chinese text into meaningful tokens and control tokenization granularity.

  • Dictionary files: Provide the vocabulary that tokenizers rely on for segmentation. Dictionaries support customization and extension.

  • Dictionary update methods: Support both cold and hot updates, letting you adjust dictionaries flexibly to meet business requirements.

Tokenization rules

The IK analyzer supports two tokenization modes:

  • ik_max_word: Splits text at the finest granularity. Ideal for term-based queries.

  • ik_smart: Splits text at a coarser granularity. Ideal for phrase-based queries.

Dictionary types

The IK analyzer supports the following dictionary types.

Dictionary type

Description

File requirements

Supported update methods

Main dictionary

The default main dictionary is main.dic, containing over 270,000 Chinese words.

When you configure a main dictionary for an ES index, the cluster matches incoming data against this dictionary during indexing. Matched terms become searchable via corresponding keywords.

One word per line, saved as a UTF-8-encoded DIC file.

Stop word dictionary

The default stop word dictionary is stopword.dic, which includes English stop words such as a, the, and, at, but, etc.

When you configure a stop word dictionary for an ES index, the cluster filters out matched terms during indexing. Filtered terms are excluded from the inverted index.

Preposition dictionary

The default preposition dictionary is preposition.dic, which stores prepositions to help the tokenizer split prepositions from subsequent words.

Not applicable

Cold update

Quantifier dictionary

The default quantifier dictionary is quantifier.dic, which stores unit-related terms and quantifiers to help the tokenizer recognize quantifier-noun combinations.

suffix.dic

Stores suffix terms to help the tokenizer split words with suffixes.

Not applicable

Update not supported

surname.dic

Stores common Chinese surnames to help the tokenizer recognize names.

Dictionary update methods

Update dictionaries when the defaults do not meet your needs. The IK analyzer supports the following methods.

Update method

Description

Scenarios

Cold update

Restarts the ES cluster to apply dictionary changes to all nodes.

Uploaded files are delivered to all ES nodes, and the nodes restart. Changes take effect after the restart completes.

  • Replace or delete content in default dictionary files.

  • Update preposition or quantifier dictionary files.

Hot update

  • If only the content of existing dictionaries changes and file names remain unchanged, the cluster loads the new dictionaries dynamically without restarting.

  • If dictionary file names change or the dictionary file list changes (adding, removing, or renaming files), the cluster restarts to reload the configuration. The updated configuration takes effect after the restart completes. This includes first-time hot update configurations.

Note

Only supports updating main or stop word dictionaries.

Important

When you configure hot update for the first time or change the dictionary file list (add, delete, or rename dictionary files), the cluster restarts. Only subsequent content-only changes to existing dictionary files with unchanged file names take effect dynamically without a restart. Schedule these operations during off-peak hours to avoid impacting your business.

  • Extend main or stop word dictionaries by adding custom dictionary files beyond the defaults.

  • Modify the content of existing main or stop word dictionary files (including default and extended dictionaries).

Prerequisites

  • The instance is in Normal state. View the instance status on the details page.

    Note

    This topic uses an Alibaba Cloud ES instance running version 7.10.0. Console interfaces and features may differ across versions.

  • (Optional) If you plan to update dictionaries, complete the following steps first.

    • To update using Upload OSS File: First create an OSS bucket and upload the required dictionary files.

    • To update using Upload On-premises File: Save the required dictionary files to your local machine first.

Update IK dictionaries

Update IK dictionaries when the defaults do not meet your needs. Review the update method before proceeding. For indexes already configured with IK tokenization, dictionary updates apply only to new data. To apply changes to existing data, recreate the index.

Cold update

To perform a cold update:

Warning

Cold updates restart the cluster. Perform this during off-peak hours.

  1. Go to the instance details page.

    1. Log on to the Alibaba Cloud Elasticsearch console.

    2. In the navigation pane on the left, click Elasticsearch Clusters.

    3. In the top menu bar, select a resource group and region.

    4. In the Elasticsearch instance list, click the target instance ID to go to its details page.

  2. Go to the cold update page for the analysis-ik plugin.

    1. In the navigation pane on the left, choose Configuration and Management > Plug-ins.

    2. On the Built-in Plug-ins tab, find the analysis-ik plugin and click Standard Update in the Actions column.

  3. Perform the cold update.

    1. In the Configure IK Dictionaries - Standard Update dialog box, click Edit next to the target dictionary, upload the required dictionary file as instructed, then click Save.

      You can upload dictionary files using one of the following methods:

      • Upload On-premises File: Click the image icon or drag and drop your local file as instructed.

      • Upload OSS File: Enter the bucket name and dictionary file name, then click Add.

        • The bucket and Alibaba Cloud ES instance must be in the same region.

        • OSS dictionary files are not automatically synchronized. If the source file changes, perform a dictionary update to apply changes.

      Note
    2. Select the risk acknowledgment and click OK to restart the instance.

      After the instance restarts, the dictionary update is complete.

  4. (Optional) Test whether the dictionary update took effect.

    1. Log on to the Kibana console.

    2. Click the image icon in the upper-left corner and choose Management > Developer Tools to open the code editor.

      Run the following code to perform coarse-grained tokenization on the input text Chinese character input method for computers.

      Note

      In practice, replace the text value with a word from your dictionary.

      GET _analyze
      {
        "analyzer": "ik_smart",
        "text": "Chinese character input method for computers"
      }

      The expected response is as follows.

      {
        "tokens" : [
          {
            "token" : "computer",
            "start_offset" : 0,
            "end_offset" : 3,
            "type" : "CN_WORD",
            "position" : 0
          },
          {
            "token" : "Chinese character input",
            "start_offset" : 3,
            "end_offset" : 7,
            "type" : "CN_WORD",
            "position" : 1
          },
          {
            "token" : "method",
            "start_offset" : 7,
            "end_offset" : 9,
            "type" : "CN_WORD",
            "position" : 2
          }
        ]
      }

Hot update

To perform a hot update:

Note

Content-only changes to existing dictionary files with unchanged file names do not restart the cluster. If dictionary file names or the file count changes, or if you are configuring hot update for the first time, the cluster restarts. Perform this operation during off-peak hours to minimize business impact. After the restart, the dictionary takes effect automatically.

  1. Go to the instance details page.

    1. Log on to the Alibaba Cloud Elasticsearch console.

    2. In the navigation pane on the left, click Elasticsearch Clusters.

    3. In the top menu bar, select a resource group and region.

    4. In the Elasticsearch instance list, click the target instance ID to go to its details page.

  2. Go to the hot update page for the analysis-ik plugin.

    1. In the navigation pane on the left, choose Configuration and Management > Plug-ins.

    2. On the Built-in Plug-ins tab, find the analysis-ik plugin and click Rolling Update in the Actions column.

  3. Perform the hot update.

    1. In the Configure IK Dictionaries - Rolling Update dialog box, click Edit next to the target dictionary, upload the required dictionary file as instructed, then click Save.

      You can upload dictionary files using one of the following methods:

      • Upload On-premises File: Click the image icon or drag and drop your local file as instructed.

      • Upload OSS File: Enter the bucket name and dictionary file name, then click Add.

        • The bucket and Alibaba Cloud ES instance must be in the same region.

        • OSS dictionary files are not automatically synchronized. If the source file changes, perform a dictionary update to apply changes.

      Note
      • You can upload multiple dictionary files. File names must end with .dic. File names can contain letters, digits, and underscores, and must not exceed 30 characters.

      • To modify an uploaded dictionary file, click the Download icon next to it to download and edit the file. Then delete the original file and re-upload the updated one. After deleting the original file, click Save; otherwise, the system reports that a file with the same name already exists.

    2. Click OK and wait for ES nodes to finish loading the dictionary.

      ES nodes load dictionary files automatically. Loading times vary across nodes — wait until all nodes finish.

  4. (Optional) Test whether the dictionary update took effect.

    1. Log on to the Kibana console.

    2. Click the image icon in the upper-left corner and choose Management > Developer Tools to open the code editor.

      Run the following code to perform coarse-grained tokenization on the input text Chinese character input method for computers.

      Note

      In practice, replace the text value with a word from your dictionary.

      GET _analyze
      {
        "analyzer": "ik_smart",
        "text": "Chinese character input method for computers"
      }

      The expected response is as follows.

      {
        "tokens" : [
          {
            "token" : "computer",
            "start_offset" : 0,
            "end_offset" : 3,
            "type" : "CN_WORD",
            "position" : 0
          },
          {
            "token" : "Chinese character input",
            "start_offset" : 3,
            "end_offset" : 7,
            "type" : "CN_WORD",
            "position" : 1
          },
          {
            "token" : "method",
            "start_offset" : 7,
            "end_offset" : 9,
            "type" : "CN_WORD",
            "position" : 2
          }
        ]
      }

Use the IK analyzer plugin

Tokenize text using the IK tokenizer with a Pinyin filter.

  1. Go to the Kibana Developer Tools page for your ES instance.

    1. Log on to the Kibana console.

    2. Click the image icon in the upper-left corner and choose Management > Developer Tools to open the code editor.

  2. Create an index and configure the IK tokenizer and Pinyin filter.

    Run the following command to create the ik_pinyin index with a custom ik_pinyin_analyzer. This analyzer uses ik_max_word tokenization and a Pinyin filter to convert Chinese terms into Pinyin.

    Note

    The Pinyin filter converts tokens to Pinyin after Chinese tokenization completes.

    PUT ik_pinyin
    {
      "settings":{
        "analysis": {
          "filter": {
            "my_pinyin" : {
                "type" : "pinyin",
                "keep_separate_first_letter" : false,
                "keep_full_pinyin" : true,
                "keep_original" : true,
                "limit_first_letter_length" : 16,
                "lowercase" : true,
                "remove_duplicated_term" : true
              }
          },
          "analyzer": {
            "ik_pinyin_analyzer": {
              "type": "custom",
              "tokenizer": "ik_max_word",
              "filter": ["my_pinyin"]
            }
          }
        }
      },
      "mappings":{
        "properties":{
          "text":{
            "type" : "text",
            "analyzer" : "ik_pinyin_analyzer"
          }
        }
      }
    }

    Key parameters are described below.

    • Pinyin filter (the filter)

      Note

      All available parameters are documented in Pinyin Analysis for Elasticsearch.

      Parameter

      Description

      my_pinyin

      The name of the custom Pinyin filter.

      type

      Set to pinyin to use a Pinyin filter.

      keep_separate_first_letter

      Set to false to exclude individual first-letter tokens for each character.

      keep_full_pinyin

      Set to true to include full Pinyin forms.

      keep_original

      Set to true to retain the original input text.

      limit_first_letter_length

      Set to 16 to limit first-letter sequences to 16 characters.

      lowercase

      Set to true to output Pinyin in lowercase.

      remove_duplicated_term

      Set to true to remove duplicate terms, such as avoiding "zh, zh".

    • Analyzer (the analyzer):

      Parameter

      Description

      ik_pinyin_analyzer

      The name of the custom analyzer.

      type

      Set to custom to define a custom analyzer.

      tokenizer

      Set to ik_max_word to split text at the finest granularity.

      filter

      Set to my_pinyin to apply the my_pinyin Pinyin filter.

      A successful result is as follows.

      {
        "acknowledged": true,
        "shards_acknowledged": true,
        "index": "ik_pinyin"
      }
  3. Verify tokenization results.

    Run the following code to tokenize the input text This is a test.

    GET ik_pinyin/_analyze
    {
      "text": "This is a test",
      "analyzer": "ik_pinyin_analyzer"
    }

    The expected response is as follows.

    {
      "tokens" : [
        {
          "token" : "zhe",
          "start_offset" : 0,
          "end_offset" : 2,
          "type" : "CN_WORD",
          "position" : 0
        },
        {
          "token" : "this is",
          "start_offset" : 0,
          "end_offset" : 2,
          "type" : "CN_WORD",
          "position" : 0
        },
        {
          "token" : "zs",
          "start_offset" : 0,
          "end_offset" : 2,
          "type" : "CN_WORD",
          "position" : 0
        },
        {
          "token" : "shi",
          "start_offset" : 0,
          "end_offset" : 2,
          "type" : "CN_WORD",
          "position" : 1
        },
        {
          "token" : "ge",
          "start_offset" : 2,
          "end_offset" : 3,
          "type" : "CN_CHAR",
          "position" : 2
        },
        {
          "token" : "one",
          "start_offset" : 2,
          "end_offset" : 3,
          "type" : "CN_CHAR",
          "position" : 2
        },
        {
          "token" : "g",
          "start_offset" : 2,
          "end_offset" : 3,
          "type" : "CN_CHAR",
          "position" : 2
        },
        {
          "token" : "ce",
          "start_offset" : 3,
          "end_offset" : 5,
          "type" : "CN_WORD",
          "position" : 3
        },
        {
          "token" : "shi",
          "start_offset" : 3,
          "end_offset" : 5,
          "type" : "CN_WORD",
          "position" : 4
        },
        {
          "token" : "test",
          "start_offset" : 3,
          "end_offset" : 5,
          "type" : "CN_WORD",
          "position" : 4
        },
        {
          "token" : "cs",
          "start_offset" : 3,
          "end_offset" : 5,
          "type" : "CN_WORD",
          "position" : 4
        }
      ]
    }
    

Optimize tokenization for alphanumeric mixed words

When you use the ik_max_word tokenizer, alphanumeric mixed strings such as fawjh6bcm may not be tokenized effectively for search. To improve recall, set enable_single_word to true. This splits mixed words into single-character tokens, enabling character-level matching.

The following example creates a custom analyzer with enable_single_word enabled:

PUT my_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "ik_single_char_analyzer": {
          "type": "custom",
          "tokenizer": "my_ik_tokenizer"
        }
      },
      "tokenizer": {
        "my_ik_tokenizer": {
          "type": "ik_max_word",
          "enable_single_word": true
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "ik_single_char_analyzer"
      }
    }
  }
}

Parameter

Description

enable_single_word

Set to true to split alphanumeric mixed strings into individual character tokens, improving recall for strings like model numbers or serial codes. Default: false.

Note

This parameter is also supported in Alibaba Cloud Elasticsearch Serverless environments.

Use the ngram tokenizer for mixed Chinese-English search

When searching for concatenated English model numbers (such as jh6bcm) mixed with Chinese text, the IK analyzer alone may not produce effective tokens for partial matching. In this case, use the ngram tokenizer to complement or replace the IK analyzer.

The ngram tokenizer breaks text into contiguous character sequences of configurable length, enabling substring matching.

The following example creates an index that uses the ngram tokenizer:

PUT my_ngram_index
{
  "settings": {
    "analysis": {
      "tokenizer": {
        "my_ngram_tokenizer": {
          "type": "ngram",
          "min_gram": 2,
          "max_gram": 3,
          "token_chars": ["letter", "digit"]
        }
      },
      "analyzer": {
        "ngram_analyzer": {
          "type": "custom",
          "tokenizer": "my_ngram_tokenizer"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "model_number": {
        "type": "text",
        "analyzer": "ngram_analyzer"
      }
    }
  }
}

Parameter

Description

min_gram

The minimum character length of a gram. Default: 1.

max_gram

The maximum character length of a gram. Default: 2.

token_chars

The character classes to include in tokens. Valid values: letter, digit, whitespace, punctuation, symbol.

For more information about the ngram tokenizer configuration, see Ngram tokenizer.

FAQ

Uppercase words in synonym files cause errors. What do I do?

The IK analyzer is case-sensitive when processing synonym files. If a synonym file contains uppercase words (such as IT), parsing errors may occur during indexing.

You can resolve this issue using either of the following methods.

  • Convert all synonyms to lowercase: Edit your synonym file and convert all entries to lowercase before uploading.

  • Add a lowercase filter to the analyzer: Add a lowercase filter before the synonym filter in your analyzer configuration to normalize text before synonym matching. Example:

    PUT my_index
    {
      "settings": {
        "analysis": {
          "filter": {
            "my_synonym_filter": {
              "type": "synonym",
              "synonyms_path": "your_synonyms.txt"
            }
          },
          "analyzer": {
            "ik_synonym_analyzer": {
              "type": "custom",
              "tokenizer": "ik_max_word",
              "filter": ["lowercase", "my_synonym_filter"]
            }
          }
        }
      }
    }
    Important

    The lowercase filter must appear before the synonym filter in the filter chain to ensure text is converted to lowercase before synonym matching occurs.

References