跳到主要内容

refresh_external_collection()

公测版

此操作会扫描 Schema 定义的外部存储中的数据文件,并生成元数据文件,用于记录其与这些数据文件之间的映射关系。

Notes

这需要使用项目 Endpoint 按如下方式设置一个 MilvusClient:

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

请求语法​

python
refresh_external_collection(
collection_name: str,
external_source: str = "",
external_spec: str = "",
timeout: Optional[float] = None,
**kwargs,
) -> int

参数:

  • collection_name (string) -

    [必需]

    现有外部 Collection 的名称。

  • external_source (str) -

    外部源 URI,应为指向可访问外部卷的 volume:// URI。例如,volume://<volume-name>/path/to/folder/..

  • external_spec (str) -

    外部源规格,即一组次级参数:

    • format (str) -

      目标源数据文件的格式。

      可能的值包括 parquet、vortex、lance-table 和 iceberg-table。

    • snapshot_id (str) -

      Iceberg 表的 ID。仅当 format 为 iceberg-table 时适用。

  • timeout (float) -

    此操作的超时时长。

    将其设置为 None 表示当收到任何响应或发生任何错误时,此操作即超时。

返回类型:

int

返回:

一个整数,表示已创建的异步作业。

示例​

python
from pymilvus import MilvusClient

# 1. Set up a milvus client
client = MilvusClient(
uri="YOUR_PROJECT_ENDPOINT",
token="YOUR_API_KEY"
)

job_id = client.refresh_external_collection(
collection_name="test_collection"
)

while True:
progress = client.get_refresh_external_collection_progress(job_id=job_id)
print(f" {progress.state}: {progress.progress}%")

if progress.state == "RefreshCompleted":
elapsed = progress.end_time - progress.start_time
print(f" Completed in {elapsed}ms")
return job_id
elif progress.state == "RefreshFailed":
print(f" Failed: {progress.reason}")
return job_id

time.sleep(2)
最低 SDK 版本v3.0.x