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

Standard Analyzer

standard analyzer は Zilliz Cloud のデフォルト analyzer であり、analyzer が指定されていない場合にテキストフィールドへ自動的に適用されます。文法ベースの tokenization を使用するため、ほとんどの言語で効果的です。

📘注意

standard analyzer は、単語境界に区切り文字(スペースや句読点など)を使用する言語に適しています。ただし、中国語、日本語、韓国語のような言語では辞書ベースの tokenization が必要です。そのような場合は、正確な tokenization とより良い検索結果を得るために、chinese のような言語固有の analyzer、または専用 tokenizer(linderaicu など)と filter を組み合わせたカスタム analyzer の使用を強く推奨します。

Definition

standard analyzer は以下で構成されます。

  • Tokenizer: standard tokenizer を使用して、文法ルールに基づきテキストを個別の単語単位に分割します。詳細は Standard Tokenizer を参照してください。

  • Filter: lowercase filter を使用してすべての token を小文字に変換し、大文字小文字を区別しない検索を可能にします。詳細は Lowercase を参照してください。

standard analyzer の機能は、以下のカスタム analyzer 設定と同等です。

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

Configuration

フィールドに standard analyzer を適用するには、analyzer_params 内で typestandard に設定し、必要に応じてオプションのパラメータを含めます。

python
analyzer_params = {
"type": "standard", # Specifies the standard analyzer type
}

standard analyzer は以下のオプションパラメータを受け付けます。

ParameterDescription
stop_wordsstop word のリストを含む配列で、tokenization から除外されます。

カスタム stop word の設定例:

python
analyzer_params = {
"type": "standard", # Specifies the standard analyzer type
"stop_words", ["of"] # Optional: List of words to exclude from tokenization
}

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

Examples

analyzer 設定を collection schema に適用する前に、run_analyzer メソッドを使用してその動作を確認してください。

Analyzer configuration

python
analyzer_params = {
"type": "standard", # Standard analyzer configuration
"stop_words": ["for"] # Optional: Custom stop words parameter
}

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
Standard analyzer output: ['the', 'milvus', 'vector', 'database', 'is', 'built', 'scale']