{
  "id": "chinese",
  "title": "Chinese support",
  "url": "https://redis.io/docs/latest/develop/ai/search-and-query/advanced-concepts/chinese/",
  "summary": "Chinese support for searching and querying in Redis Open Source",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-04-01T08:10:08-05:00",
  "page_type": "content",
  "content_hash": "317cd004dc280ff73b9c46061cac13e6caa91ae7f4e94faad137334912dbe6dc",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Support for adding documents in Chinese is available starting at version 0.99.0.\n\nChinese support allows Chinese documents to be added and tokenized using segmentation\nrather than simple tokenization using whitespace and/or punctuation.\n\nIndexing a Chinese document is different than indexing a document in most other\nlanguages because of how tokens are extracted. While most languages can have\ntheir tokens distinguished by separation characters and whitespace, this\nis not common in Chinese.\n\nChinese tokenization is done by scanning the input text and checking every\ncharacter or sequence of characters against a dictionary of predefined terms,\nand determining the most likely match based on the surrounding terms and characters.\n\nRedis makes use of the [Friso](https://github.com/lionsoul2014/friso)\nChinese tokenization library for this purpose. This is largely transparent to\nthe user and often no additional configuration is required."
    },
    {
      "id": "example-using-chinese-in-queries",
      "title": "Example: using chinese in queries",
      "role": "example",
      "text": "In pseudo-code:\n\n[code example]\n\nUsing the Python client:\n\n[code example]"
    },
    {
      "id": "using-custom-dictionaries",
      "title": "Using custom dictionaries",
      "role": "content",
      "text": "If you wish to use a custom dictionary, you can do so at the module level when\nloading the module. The `FRISOINI` setting can point to the location of a\n`friso.ini` file that contains the relevant settings and paths to the dictionary\nfiles.\n\nNote that there is no default `friso.ini` file location. RediSearch comes with\nits own `friso.ini` and dictionary files, which are compiled into the module\nbinary at build-time."
    }
  ],
  "examples": [
    {
      "id": "example-using-chinese-in-queries-ex0",
      "language": "plaintext",
      "code": "FT.CREATE idx ON HASH SCHEMA txt TEXT\nHSET docCn txt \"Redis支持主从同步。数据可以从主服务器向任意数量的从服务器上同步，从服务器可以是关联其他从服务器的主服务器。这使得Redis可执行单层树复制。从盘可以有意无意的对数据进行写操作。由于完全实现了发布/订阅机制，使得从数据库在任何地方同步树时，可订阅一个频道并接收主服务器完整的消息发布记录。同步对读取操作的可扩展性和数据冗余很有帮助。[8]\"\nFT.SEARCH idx \"数据\" LANGUAGE chinese HIGHLIGHT SUMMARIZE\n# Outputs:\n# <b>数据</b>?... <b>数据</b>进行写操作。由于完全实现了发布... <b>数据</b>冗余很有帮助。[8...",
      "section_id": "example-using-chinese-in-queries"
    },
    {
      "id": "example-using-chinese-in-queries-ex1",
      "language": "plaintext",
      "code": "# -*- coding: utf-8 -*-\n\nfrom redisearch.client import Client, Query\nfrom redisearch import TextField\n\nclient = Client('idx')\ntry:\n    client.drop_index()\nexcept:\n    pass\n\nclient.create_index([TextField('txt')])\n\n# Add a document\nclient.add_document('docCn1',\n                    txt='Redis支持主从同步。数据可以从主服务器向任意数量的从服务器上同步从服务器可以是关联其他从服务器的主服务器。这使得Redis可执行单层树复制。从盘可以有意无意的对数据进行写操作。由于完全实现了发布/订阅机制，使得从数据库在任何地方同步树时，可订阅一个频道并接收主服务器完整的消息发布记录。同步对读取操作的可扩展性和数据冗余很有帮助。[8]',\n                    language='chinese')\nprint client.search(Query('数据').summarize().highlight().language('chinese')).docs[0].txt\n# Outputs:\n# <b>数据</b>?... <b>数据</b>进行写操作。由于完全实现了发布... <b>数据</b>冗余很有帮助。[8...",
      "section_id": "example-using-chinese-in-queries"
    }
  ]
}
