index_building_progress()
Near Deprecation此操作返回索引构建过程的进度。
请求语法
python
index_building_progress(
collection_name: str,
index_name: str = "",
using: str = "default",
timeout: float | None,
)
参数:
-
collection_name (str) -
【必需】
现有 Collection 的名称。
将其设置为不存在的 Collection 会导致 CollectionNotExistException。
-
index_name (str) -
此操作的目标索引名称。
如果未指定,则使用默认索引。如果该 Collection 有多个索引,则此参数为必填。
将其设置为不存在的索引会导致 IndexNotExistException。
-
using (str) -
所使用连接的别名。
默认值为 default,表示此操作使用默认连接。
-
timeout (float | None)
此操作的超时时长。将其设置为 None 表示当收到任何响应或发生任何错误时,此操作即超时。
返回类型:
dict
返回: 一个字典,包含指定 Collection 中已建立索引的 Entity 数量以及 Entity 总数。 该字典包含以下键:
-
total_rows (int)
指定 Collection 中的 Entity 总数。
-
indexed_rows (int)
指定 Collection 中已建立索引的 Entity 数量。
-
pending_index_rows (int)
等待建立索引的 Entity 数量。
异常:
-
CollectionNotExistException
如果指定的 Collection 不存在,则会引发此异常。
-
IndexNotExistException
如果指定的索引不存在,则会引发此异常。
-
AmbiguousIndexName
如果存在多个索引但未指定索引名称,则会引发此异常。
示例
python
from pymilvus import (
connections,
Collection,
CollectionSchema,
FieldSchema,
DataType,
utility,
)
# Connection to YOUR_CLUSTER_ENDPOINT
connections.connect()
# Create a collection
collection = Collection(
name="test_collection",
schema=CollectionSchema([
FieldSchema("id", DataType.INT64, is_primary=True),
FieldSchema("vector", DataType.FLOAT_VECTOR, dim=5)
])
)
# Create an index on a scalar field
collection.create_index(
field_name="id"
)
# Set the index parameters
index_params = {
"index_type": "AUTOINDEX",
"metric_type": "COSINE",
"params": {
"nprobe": 10
}
}
# Create an index on the vector field
collection.create_index(
field_name="vector",
index_params=index_params,
timeout=None
)
# List all indexes
utility.list_indexes(
collection_name="test_collection"
) # ['_default_idx_101', '_default_idx_100']
# Get the building progress of a specific index
utility.index_building_progress(
collection_name="test_collection",
index_name="_default_idx_101"
)
相关操作
以下操作与 index_building_progress() 相关