Upsert()
Inserts new entities or updates existing entities in a collection.
pub async fn upsert(&self, request: UpsertRequest) -> Result<UpsertResponse>
Request Syntax
let request = UpsertRequest::builder()
.insert(
InsertRequest::builder()
.collection_name("books")
.rows(vec![EntityRow::from_iter([
("id".into(), json!(1)),
("title".into(), json!("Milvus")),
])])
.build()?,
)
.partial_update(false)
.build()?;
REQUEST FIELDS:
insert: InsertRequestThe
InsertRequestthat carries the collection name and the entity data. Required.partial_update: boolWhether the upsert applies a partial update. Implicitly enabled when any field operation uses a non-
Replaceoperation type.field_ops: Vec<FieldPartialUpdateOp>Per-field operations applied during a partial update, such as
ArrayAppendorArrayRemove. Each operation requires a field name.
RETURNS:
Result
UpsertResponse is an alias for DmlResponse, which contains the assigned primary keys (ids), per-row success or failure indices, the upsert count, and the mutation timestamp. Returns Error on failure.
Example
let request = UpsertRequest::builder()
.insert(
InsertRequest::builder()
.collection_name("books")
.rows(vec![EntityRow::from_iter([
("id".into(), json!(1)),
("title".into(), json!("Milvus")),
])])
.build()?,
)
.build()?;
let resp = client.upsert(request).await?;