メインコンテンツまでスキップ

Whitespace

whitespace tokenizer は、単語間にスペースがあるたびにテキストを語に分割します。

Configuration

whitespace tokenizer を使用して analyzer を構成するには、analyzer_paramstokenizerwhitespace に設定します。

python
analyzer_params = {
"tokenizer": "whitespace",
}

whitespace tokenizer は、1 つ以上の filter と組み合わせて動作させることができます。たとえば、次のコードは whitespace tokenizer と lowercase filter を使用する analyzer を定義しています。

python
analyzer_params = {
"tokenizer": "whitespace",
"filter": ["lowercase"]
}

analyzer_params を定義した後、collection schema を定義する際にそれらを VARCHAR フィールドに適用できます。これにより、Zilliz Cloud は効率的な tokenization と filtering のために、指定した analyzer を使用してそのフィールド内のテキストを処理できます。詳細については、Example use を参照してください。

Examples

analyzer 構成を collection schema に適用する前に、run_analyzer メソッドを使用してその動作を検証してください。

Analyzer configuration

python
analyzer_params = {
"tokenizer": "whitespace",
"filter": ["lowercase"]
}

Verification using run_analyzer

python
from pymilvus import (
MilvusClient,
)

client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)

# Sample text to analyze
sample_text = "The Milvus vector database is built for scale!"

# Run the standard analyzer with the defined configuration
result = client.run_analyzer(sample_text, analyzer_params)
print("Standard analyzer output:", result)

Expected output

sql
['the', 'milvus', 'vector', 'database', 'is', 'built', 'for', 'scale!']
Ctrl I