1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#[tokio::test]
async fn test_batch_update() {
async fn batch_update() -> Result<(), Box<dyn std::error::Error>> {
// WARNING: This is a generated test snippet.
// Please, modify the snippet in the `../snippets/batch_update.rs` file
use qdrant_client::qdrant::{
points_selector::PointsSelectorOneOf,
points_update_operation::{
Operation, OverwritePayload, PointStructList, UpdateVectors,
},
PointStruct, PointVectors, PointsIdsList, PointsSelector, PointsUpdateOperation,
UpdateBatchPointsBuilder,
};
use qdrant_client::{Qdrant, Payload};
use serde_json::json;
use std::collections::HashMap;
let client = Qdrant::from_url("http://localhost:6334").build()?;
client
.update_points_batch(
UpdateBatchPointsBuilder::new(
"{collection_name}",
vec![
PointsUpdateOperation {
operation: Some(Operation::Upsert(PointStructList {
points: vec![PointStruct::new(
1,
vec![1.0, 2.0, 3.0, 4.0],
Payload::try_from(json!({})).unwrap(),
)],
..Default::default()
})),
},
PointsUpdateOperation {
operation: Some(Operation::UpdateVectors(UpdateVectors {
points: vec![PointVectors {
id: Some(1.into()),
vectors: Some(vec![1.0, 2.0, 3.0, 4.0].into()),
}],
..Default::default()
})),
},
PointsUpdateOperation {
operation: Some(Operation::OverwritePayload(OverwritePayload {
points_selector: Some(PointsSelector {
points_selector_one_of: Some(PointsSelectorOneOf::Points(
PointsIdsList {
ids: vec![1.into()],
},
)),
}),
payload: HashMap::from([("test_payload".to_string(), 1.into())]),
..Default::default()
})),
},
],
)
.wait(true),
)
.await?;
Ok(())
}
let _ = batch_update().await;
}