transfer_replica()
Near Deprecation此操作用于在资源组之间转移指定数量的副本。
请求语法
python
transfer_replica(
source_group: str,
target_group: str,
collection_name: str,
num_replicas: int,
using: str = "default",
timeout: float | None,
)
参数:
-
source_group (str) -
[必需]
要从中移出查询节点的源资源组名称。
如果将其设置为不存在的资源组,则会导致 MilvusException。
-
target_group (str) -
[必需]
要将查询节点移入的源资源组名称。
如果将其设置为不存在的资源组,则会导致 MilvusException。
-
num_replicas (int) -
[必需]
在源资源组和目标资源组之间移动的副本数量。
-
using (str) -
所用连接的别名。
默认值为 default,表示此操作使用默认连接。
-
timeout (float | None)
此操作的超时时长。将其设置为 None 表示当收到任何响应或发生任何错误时,此操作即超时。
返回类型:
NoneType
返回值:
None。
异常:
-
MilvusException
当此操作期间发生任何错误时,将引发此异常。
示例:
python
from pymilvus import (
connections,
Collection,
CollectionSchema,
FieldSchema,
DataType,
utility,
)
# Connect 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)
])
)
# Get the currently loaded replicas
collection.get_replicas()
# Create a new resource group
utility.create_resource_group(
name="rg_01",
using="default"
)
# Transfer replicas between resource groups
utility.transfer_node(
source_group="__default_resource_group",
target_group="rg_01",
num_nodes=1
)
相关操作
以下操作与 transfer_replica() 相关: