wait_for_index_building_complete()
Near Deprecation此操作会阻塞当前进程,直到指定索引构建完成。
请求语法
python
wait_for_index_building_complete(
collection_name: str,
index_name: str = "",
timeout: float | None,
using: str = "default",
)
参数:
-
collection_name (str) -
[必需]
现有 Collection 的名称。
如果将其设置为不存在的 Collection,则会导致 CollectionNotExistException。
-
index_name (str) -
此操作目标索引的名称。
如果未指定,则使用默认索引。如果 Collection 有多个索引,则此参数为必填。
如果将其设置为不存在的索引,则会导致 IndexNotExistException。
-
using (str) -
所使用连接的别名。
默认值为 default,表示此操作使用默认连接。
-
timeout (float | None)
此操作的超时时长。将其设置为 None 表示当收到任意响应或发生任何错误时,此操作超时。
返回类型:
NoneType
返回值:
None
异常:
-
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']
# Wait for the index being built
utility.wait_for_index_building_complete(
collection_name="test_collection",
index_name="_default_idx_100",
)
相关操作
以下操作与 wait_for_index_building_complete() 相关