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

list_indexes()

この操作は、特定のコレクションのすべてのインデックスを一覧表示します。

Notes

このメソッドは、Dedicated serving クラスターとオンデマンドコンピュートにのみ適用されます。

  • serving クラスターのコレクションでこの操作を行うには、クラスターエンドポイントを使用して MilvusClient を作成してください。

    • Free & Serverless

      https://{cluster-id}.serverless.{region}.vectordb.zillizcloud.com

    • Dedicated

      https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530

  • オンデマンドコンピュート用のコレクションでこの操作を行うには、プロジェクトエンドポイントを使用して MilvusClient を作成し、その後、検索のためにオンデマンドクラスターに接続するセッションを作成してください。

    https://{project-id}.{region}.api.zillizcloud.com

リクエスト構文​

python
list_indexes(
collection_name: str,
field_name: Optional[str],
**kwargs,
) -> List

パラメーター:

  • collection_name (str) -

    [必須]

    既存のコレクションの名前です。

  • field_name (str) -

    フィールドの名前です。これを指定しない場合、この操作はすべてのインデックスを一覧表示します。

戻り値の型:

List

戻り値:

インデックス名のリストです。

例外:

  • MilvusException

    この操作中に何らかのエラーが発生した場合、この例外が発生します。

例​

python
from pymilvus import MilvusClient, DataType

client = MilvusClient(
uri="https://inxx-xxxxxxxxxxxx.api.gcp-us-west1.zillizcloud.com:19530",
token="user:password"
)

# 1. Create schema
schema = MilvusClient.create_schema(
auto_id=False,
enable_dynamic_field=False,
)

# 2. Add fields to schema
schema.add_field(field_name="my_id", datatype=DataType.INT64, is_primary=True)

# {
# 'auto_id': False,
# 'description': '',
# 'fields': [
# {
# 'name': 'my_id',
# 'description': '',
# 'type': <DataType.INT64: 5>,
# 'is_primary': True,
# 'auto_id': False
# }
# ]
# }

schema.add_field(field_name="my_vector", datatype=DataType.FLOAT_VECTOR, dim=5)

# {
# 'auto_id': False,
# 'description': '',
# 'fields': [
# {
# 'name': 'my_id',
# 'description': '',
# 'type': <DataType.INT64: 5>,
# 'is_primary': True,
# 'auto_id': False
# },
# {
# 'name': 'my_vector',
# 'description': '',
# 'type': <DataType.FLOAT_VECTOR: 101>,
# 'params': {
# 'dim': 5
# }
# }
# ]
# }

# 3. Create index parameters
index_params = client.prepare_index_params()

# 4. Add indexes
# - For a scalar field
index_params.add_index(
field_name="my_id",
index_type="STL_SORT"
)

# - For a vector field
index_params.add_index(
field_name="my_vector",
index_type="IVF_FLAT",
metric_type="L2",
params={"nlist": 1024}
)

# 5. Create a collection
client.create_collection(
collection_name="customized_setup",
schema=schema
)

# 6. Create indexes
client.create_index(
collection_name="customized_setup",
index_params=index_params
)

# 6. List indexes
client.list_indexes(collection_name="customized_setup")

# # ['my_id', 'my_vector']