メインコンテンツまでスキップ
バージョン: User Guides (Cloud)

インデックススカラーフィールド

Zilliz Cloudでは、従来のデータベースインデックスと同様に、特定の非ベクトルフィールド値によるメタフィルタリングを高速化するためにスカラーインデックスが使用されます。このガイドでは、整数、文字列などのフィールドのスカラーインデックスの作成と設定について説明します。

自動インデックス作成

自動インデックスを使用するには、Milvusがスカラーフィールドタイプに基づいてインデックスタイプを推測できるように、index_typeパラメータを省略してください。スカラーデータ型とデフォルトのインデックスアルゴリズムのマッピングについては、スカラーフィールドインデックスアルゴリズムを参照してください。

例えば:

# Auto indexing
CLUSTER_ENDPOINT = "YOUR_CLUSTER_ENDPOINT"
TOKEN = "YOUR_CLUSTER_TOKEN"

# 1. Set up a Milvus client
client = MilvusClient(
uri=CLUSTER_ENDPOINT,
token=TOKEN
)

index_params = client.prepare_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters

index_params.add_index(
field_name="scalar_1", # Name of the scalar field to be indexed
index_type="", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.
index_name="default_index" # Name of the index to be created
)

client.create_index(
collection_name="test_scalar_index", # Specify the collection name
index_params=index_params
)