mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-05 10:58:32 +02:00
This commit both: - Fixes pre-existing mistakes in snippets, aka wrong code samples. - Adds hidden (`@hide`) statements that do not appear in the docs, but satisfy typecheckers.
92 lines
3.9 KiB
Rust
92 lines
3.9 KiB
Rust
use std::collections::HashMap;
|
|
|
|
use qdrant_client::qdrant::{
|
|
points_update_operation::{
|
|
ClearPayload, DeletePayload, DeletePoints, DeleteVectors, Operation, OverwritePayload,
|
|
PointStructList, SetPayload, UpdateVectors,
|
|
},
|
|
PointStruct, PointVectors, PointsUpdateOperation, UpdateBatchPointsBuilder, VectorsSelector,
|
|
};
|
|
use qdrant_client::Payload;
|
|
|
|
pub async fn main() -> anyhow::Result<()> {
|
|
let client = qdrant_client::Qdrant::from_url("http://localhost:6334").build()?; // @hide
|
|
|
|
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::default(),
|
|
)],
|
|
..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::DeleteVectors(DeleteVectors {
|
|
points_selector: Some(vec![1.into()].into()),
|
|
vectors: Some(VectorsSelector {
|
|
names: vec!["".into()],
|
|
}),
|
|
..Default::default()
|
|
})),
|
|
},
|
|
PointsUpdateOperation {
|
|
operation: Some(Operation::OverwritePayload(OverwritePayload {
|
|
points_selector: Some(vec![1.into()].into()),
|
|
payload: HashMap::from([("test_payload".to_string(), 1.into())]),
|
|
..Default::default()
|
|
})),
|
|
},
|
|
PointsUpdateOperation {
|
|
operation: Some(Operation::SetPayload(SetPayload {
|
|
points_selector: Some(vec![1.into()].into()),
|
|
payload: HashMap::from([
|
|
("test_payload_2".to_string(), 2.into()),
|
|
("test_payload_3".to_string(), 3.into()),
|
|
]),
|
|
..Default::default()
|
|
})),
|
|
},
|
|
PointsUpdateOperation {
|
|
operation: Some(Operation::DeletePayload(DeletePayload {
|
|
points_selector: Some(vec![1.into()].into()),
|
|
keys: vec!["test_payload_2".to_string()],
|
|
..Default::default()
|
|
})),
|
|
},
|
|
PointsUpdateOperation {
|
|
operation: Some(Operation::ClearPayload(ClearPayload {
|
|
points: Some(vec![1.into()].into()),
|
|
..Default::default()
|
|
})),
|
|
},
|
|
PointsUpdateOperation {
|
|
operation: Some(Operation::DeletePoints(DeletePoints {
|
|
points: Some(vec![1.into()].into()),
|
|
..Default::default()
|
|
})),
|
|
},
|
|
],
|
|
)
|
|
.wait(true),
|
|
)
|
|
.await?;
|
|
|
|
Ok(())
|
|
}
|