Upsert api数据结构
该方法将实体更新插入到 Milvus 中。如果集合中已存在指定字段,则该操作将覆盖现有实体;如果指定值尚不存在,则插入新实体。
实现:先insert再delete,并限制不能修改主键列。
限制:主键的autoid必须是false。
开销:会带来一定的性能开销。
一个完整的Upert例子:
import numpy as np
from pymilvus import (
connections,
Collection,
)
num_entities, dim = 4, 3
print("start connecting to Milvus")
connections.connect("default", host="192.168.230.71", port="19530")
hello_milvus = Collection("hello_milvus")
print("Start upsert entities")
rng = np.random.default_rng(seed=19530)
entities = [
[0,1,2,4000],
[10,11,12,4000],
rng.random((num_entities, dim)),
]
hello_milvus.upsert(entities)
UpsertRequest数据结构
type UpsertRequest struct {
Base *commonpb.MsgBase
DbName string
CollectionName string
PartitionName string
FieldsData []*schemapb.FieldData
HashKeys []uint32
NumRows uint32
XXX_NoUnkeyedLiteral struct{}
XXX_unrecognized []byte
XXX_sizecache int32
}