跳到主要内容

查看 Collection

您既可以查看当前连接的数据库中已创建的 Collection 名称列表,也可以针对某个 Collection 了解其详细情况。

查看 Collection 列表

如下示例演示了如何查看当前连接的数据库中已创建的 Collection 名称列表。

from pymilvus import MilvusClient, DataType

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

res = client.list_collections()

print(res)

如果您已经创建了名为 quick_setup 的 Collection,运行上述示例的结果如下:

["quick_setup"]

查看 Collection 详情

您也可以根据需要查看某个 Collection 的详细情况。如下示例代码中假设您已经创建了名为 quick_setup 的 Collection。

res = client.describe_collection(
collection_name="quick_setup"
)

print(res)

如果您已经创建了名为 quick_setup 的 Collection,运行上述示例的结果如下:

{
'collection_name': 'quick_setup',
'auto_id': False,
'num_shards': 1,
'description': '',
'fields': [
{
'field_id': 100,
'name': 'id',
'description': '',
'type': <DataType.INT64: 5>,
'params': {},
'is_primary': True
},
{
'field_id': 101,
'name': 'vector',
'description': '',
'type': <DataType.FLOAT_VECTOR: 101>,
'params': {'dim': 768}
}
],
'functions': [],
'aliases': [],
'collection_id': 456909630285026300,
'consistency_level': 2,
'properties': {},
'num_partitions': 1,
'enable_dynamic_field': True
}