Skip to content

Commit

Permalink
update rust snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
generall committed Jun 19, 2024
1 parent 7eb1e0b commit 875c010
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
9 changes: 6 additions & 3 deletions snippets/rust/batch_update.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use serde_json::json;
use qdrant_client::client::{ QdrantClient, Payload };
use std::collections::HashMap;
use qdrant_client::qdrant::{
points_selector::PointsSelectorOneOf,
points_update_operation::{
Operation, PointStructList, SetPayload, UpdateVectors,
Operation, PointStructList, UpdateVectors, OverwritePayload
},
PointStruct, PointVectors, PointsIdsList, PointsSelector, PointsUpdateOperation,
};
Expand All @@ -17,7 +20,7 @@ client
points: vec![PointStruct::new(
1,
vec![1.0, 2.0, 3.0, 4.0],
json!({}).try_into().unwrap(),
Payload::try_from(json!({})).unwrap(),
)],
..Default::default()
})),
Expand All @@ -32,7 +35,7 @@ client
})),
},
PointsUpdateOperation {
operation: Some(Operation::OverwritePayload(SetPayload {
operation: Some(Operation::OverwritePayload(OverwritePayload {
points_selector: Some(PointsSelector {
points_selector_one_of: Some(PointsSelectorOneOf::Points(
PointsIdsList {
Expand Down
2 changes: 1 addition & 1 deletion snippets/rust/collection_exists.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use qdrant_client::{client::QdrantClient, qdrant::{Condition, CountPoints, Filter}};
use qdrant_client::client::QdrantClient;

let client = QdrantClient::from_url("http://localhost:6334").build()?;

Expand Down
2 changes: 2 additions & 0 deletions snippets/rust/overwrite_payload.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use serde_json::json;
use qdrant_client::{client::QdrantClient, qdrant::{
points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector,
}};
Expand All @@ -20,5 +21,6 @@ client
.try_into()
.unwrap(),
None,
None,
)
.await?;
2 changes: 2 additions & 0 deletions snippets/rust/set_payload.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use serde_json::json;
use qdrant_client::{client::QdrantClient, qdrant::{
points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector,
}};
Expand All @@ -20,5 +21,6 @@ client
.try_into()
.unwrap(),
None,
None,
)
.await?;
3 changes: 3 additions & 0 deletions snippets/rust/update_vectors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use qdrant_client::client::QdrantClient;
use qdrant_client::qdrant::PointVectors;
use std::collections::HashMap;

let client = QdrantClient::from_url("http://localhost:6334").build()?;

client
.update_vectors_blocking(
"{collection_name}",
Expand Down
20 changes: 7 additions & 13 deletions snippets/rust/upsert_points.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use qdrant_client::{client::QdrantClient, qdrant::PointStruct};
use qdrant_client::{client::QdrantClient, client::Payload, qdrant::PointStruct};
use serde_json::json;

let client = QdrantClient::from_url("http://localhost:6334").build()?;
Expand All @@ -11,29 +11,23 @@ client
PointStruct::new(
1,
vec![0.9, 0.1, 0.1],
json!(
Payload::try_from(json!(
{"color": "red"}
)
.try_into()
.unwrap(),
)).unwrap(),
),
PointStruct::new(
2,
vec![0.1, 0.9, 0.1],
json!(
Payload::try_from(json!(
{"color": "green"}
)
.try_into()
.unwrap(),
)).unwrap(),
),
PointStruct::new(
3,
vec![0.1, 0.1, 0.9],
json!(
Payload::try_from(json!(
{"color": "blue"}
)
.try_into()
.unwrap(),
)).unwrap(),
),
],
None,
Expand Down

0 comments on commit 875c010

Please sign in to comment.