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

Alphanumonly

alphanumonly filter は、非 ASCII 文字を含むトークンを削除し、英数字の用語のみを保持します。この filter は、特殊文字や記号を除外し、基本的な文字と数字のみが関連するテキストを処理する際に役立ちます。

Configuration

alphanumonly filter は Zilliz Cloud に組み込まれています。これを使用するには、analyzer_params 内の filter セクションでその名前を指定するだけです。

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

alphanumonly filter は tokenizer によって生成された用語に対して動作するため、tokenizer と組み合わせて使用する必要があります。Zilliz Cloud で利用可能な tokenizer の一覧については、Standard Tokenizer とその関連ページを参照してください。

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

Examples

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

Analyzer configuration

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

run_analyzer を使用した検証

python
from pymilvus import (
MilvusClient,
)

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

# Sample text to analyze
sample_text = "Milvus 2.0 @ Scale! #AI #Vector_Databasé"

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

Expected output

python
['Milvus', '2', '0', 'Scale', 'AI', 'Vector']
Ctrl I