Skip to main content

Thai

The thai analyzer is a built-in analyzer for Thai text. Use this analyzer when you need Zilliz Cloud to segment Thai text into words, normalize Thai digits, lowercase mixed Latin text, and remove Thai stop words.

Configuration​

Built-in analyzers are Milvus-provided analyzer templates. To use a built-in analyzer, set type to a predefined analyzer name in analyzer_params.

To use the built-in Thai analyzer, set type to thai:

python
analyzer_params = {
"type": "thai",
}

The thai analyzer accepts the following optional parameter:

ParameterTypeDefaultDescription
stop_wordslist[str]_thai_A list of additional stop words to remove from tokenization. By default, the thai analyzer uses the built-in _thai_ dictionary. To inspect the default dictionary, refer to the Zilliz Cloud Thai stop-word list. The list is sourced from the Apache Lucene Thai stopwords file.

To add custom stop words, include stop_words:

python
analyzer_params = {
"type": "thai",
"stop_words": ["มิลวัส"],
}

Zilliz Cloud applies custom stop words in addition to the built-in _thai_ dictionary.

The built-in thai analyzer is equivalent to the following custom analyzer configuration:

python
analyzer_params = {
"tokenizer": "thai",
"filter": [
"lowercase",
"decimaldigit",
{
"type": "stop",
"stop_words": ["_thai_"],
},
],
}

This analyzer applies the following processing steps:

  • Tokenization: Uses the thai tokenizer to segment Thai text into word tokens without relying on whitespace. The tokenizer filters out whitespace and punctuation-only segments. For details, refer to Thai tokenizer.

  • Case normalization: Uses the lowercase filter, which affects Latin letters in mixed Thai/English text.

  • Digit normalization: Uses the decimaldigit filter to convert Thai digits and other Unicode decimal digits to ASCII digits.

  • Stop-word removal: Uses the stop filter with the built-in _thai_ dictionary.

  • No stemming: The built-in thai analyzer does not apply a stemmer filter.

After defining analyzer_params, you can apply the analyzer to a VARCHAR field when defining a collection schema. For details, refer to Example use.

Examples​

Before applying the analyzer configuration to your collection schema, verify its behavior using the run_analyzer method.

Analyzer configuration​

python
analyzer_params = {
"type": "thai",
}

Verification using run_analyzer​

python
from pymilvus import MilvusClient

client = MilvusClient(uri="YOUR_CLUSTER_ENDPOINT")

sample_text = "ฉันรักการค้นหาข้อความใน Milvus ๑๒๓"

result = client.run_analyzer(sample_text, analyzer_params)
print(result)

Expected output​

plaintext
['ฉัน', 'รัก', 'ค้นหา', 'ข้อความ', 'milvus', '123']