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

Length

length フィルターは、指定された長さの要件を満たさないトークンを削除し、テキスト処理中に保持されるトークンの長さを制御できるようにします。

Configuration

length フィルターは Zilliz Cloud のカスタムフィルターであり、フィルター設定で "type": "length" を設定することで指定します。長さの制限を定義するために、analyzer_params 内で辞書として設定できます。

python
analyzer_params = {
"tokenizer": "standard",
"filter":[{
"type": "length", # Specifies the filter type as length
"max": 10, # Sets the maximum token length to 10 characters
}],
}

length フィルターは、以下の設定可能なパラメーターを受け入れます。

ParameterDescription
maxトークンの最大長を設定します。この長さを超えるトークンは削除されます。

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

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

Examples

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

Analyzer configuration

python
analyzer_params = {
"tokenizer": "standard",
"filter":[{
"type": "length", # Specifies the filter type as length
"max": 10, # Sets the maximum token length to 10 characters
}],
}

run_analyzer を使用した検証

python
from pymilvus import (
MilvusClient,
)

client = MilvusClient(uri="YOUR_CLUSTER_ENDPOINT")

# Sample text to analyze
sample_text = "The length filter allows control over token length requirements for text processing."

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

Expected output

python
['The', 'length', 'filter', 'allows', 'control', 'over', 'token', 'length', 'for', 'text', 'processing']