Skip to content

Commit fbf0048

Browse files
committed
Migrate search example to query
1 parent 22a567e commit fbf0048

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ generate-snippets = []
4040
uuid = ["dep:uuid"]
4141

4242
[[example]]
43-
name = "search"
43+
name = "query"
4444
required-features = ["serde"]
4545

4646
[[example]]

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ Add necessary dependencies:
7171
cargo add qdrant-client anyhow tonic tokio serde-json --features tokio/rt-multi-thread
7272
```
7373

74-
Add search example from [`examples/search.rs`](./examples/search.rs) to your `src/main.rs`:
74+
Add query example from [`examples/query.rs`](./examples/query.rs) to your `src/main.rs`:
7575

7676
```rust
7777
use qdrant_client::qdrant::{
7878
Condition, CreateCollectionBuilder, Distance, Filter, PointStruct, ScalarQuantizationBuilder,
79-
SearchParamsBuilder, SearchPointsBuilder, UpsertPointsBuilder, VectorParamsBuilder,
79+
SearchParamsBuilder, QueryPointsBuilder, UpsertPointsBuilder, VectorParamsBuilder,
8080
};
8181
use qdrant_client::{Payload, Qdrant, QdrantError};
8282

@@ -127,16 +127,18 @@ async fn main() -> Result<(), QdrantError> {
127127
.upsert_points(UpsertPointsBuilder::new(collection_name, points))
128128
.await?;
129129

130-
let search_result = client
131-
.search_points(
132-
SearchPointsBuilder::new(collection_name, [11.; 10], 10)
130+
let query_result = client
131+
.query(
132+
QueryPointsBuilder::new(collection_name)
133+
.query(vec![11.0; 10])
134+
.limit(10)
133135
.filter(Filter::all([Condition::matches("bar", 12)]))
134136
.with_payload(true)
135137
.params(SearchParamsBuilder::default().exact(true)),
136138
)
137139
.await?;
138-
dbg!(&search_result);
139-
// search_result = [
140+
dbg!(&query_result);
141+
// query_result = [
140142
// {
141143
// "id": 0,
142144
// "version": 0,
@@ -151,10 +153,10 @@ async fn main() -> Result<(), QdrantError> {
151153
// }
152154
// ]
153155

154-
let found_point = search_result.result.into_iter().next().unwrap();
156+
let found_point = query_result.result.into_iter().next().unwrap();
155157
let mut payload = found_point.payload;
156158
let baz_payload = payload.remove("baz").unwrap().into_json();
157-
println!("baz: {}", baz_payload);
159+
println!("baz: {baz_payload}");
158160
// baz: {"qux":"quux"}
159161

160162
Ok(())
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use qdrant_client::qdrant::{
22
Condition, CreateCollectionBuilder, Distance, Filter, PointStruct, ScalarQuantizationBuilder,
3-
SearchParamsBuilder, SearchPointsBuilder, UpsertPointsBuilder, VectorParamsBuilder,
3+
SearchParamsBuilder, QueryPointsBuilder, UpsertPointsBuilder, VectorParamsBuilder,
44
};
55
use qdrant_client::{Payload, Qdrant, QdrantError};
66

@@ -51,16 +51,18 @@ async fn main() -> Result<(), QdrantError> {
5151
.upsert_points(UpsertPointsBuilder::new(collection_name, points))
5252
.await?;
5353

54-
let search_result = client
55-
.search_points(
56-
SearchPointsBuilder::new(collection_name, [11.; 10], 10)
54+
let query_result = client
55+
.query(
56+
QueryPointsBuilder::new(collection_name)
57+
.query(vec![11.0; 10])
58+
.limit(10)
5759
.filter(Filter::all([Condition::matches("bar", 12)]))
5860
.with_payload(true)
5961
.params(SearchParamsBuilder::default().exact(true)),
6062
)
6163
.await?;
62-
dbg!(&search_result);
63-
// search_result = [
64+
dbg!(&query_result);
65+
// query_result = [
6466
// {
6567
// "id": 0,
6668
// "version": 0,
@@ -75,7 +77,7 @@ async fn main() -> Result<(), QdrantError> {
7577
// }
7678
// ]
7779

78-
let found_point = search_result.result.into_iter().next().unwrap();
80+
let found_point = query_result.result.into_iter().next().unwrap();
7981
let mut payload = found_point.payload;
8082
let baz_payload = payload.remove("baz").unwrap().into_json();
8183
println!("baz: {baz_payload}");

0 commit comments

Comments
 (0)