Skip to content

Commit b87748e

Browse files
timviseeKShivendu
andauthored
Migrate search documentation/references/examples to query (#261)
* Migrate search example in docs to query * Link from search to query API in other places * Migrate search example to query * Fix invalid documentation link * Reformat * Update examples/query.rs Co-authored-by: Kumar Shivendu <kshivendu1@gmail.com> --------- Co-authored-by: Kumar Shivendu <kshivendu1@gmail.com>
1 parent 602ef49 commit b87748e

File tree

6 files changed

+50
-39
lines changed

6 files changed

+50
-39
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: 12 additions & 10 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::{
78-
Condition, CreateCollectionBuilder, Distance, Filter, PointStruct, ScalarQuantizationBuilder,
79-
SearchParamsBuilder, SearchPointsBuilder, UpsertPointsBuilder, VectorParamsBuilder,
78+
Condition, CreateCollectionBuilder, Distance, Filter, PointStruct, QueryPointsBuilder,
79+
ScalarQuantizationBuilder, SearchParamsBuilder, 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: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use qdrant_client::qdrant::{
2-
Condition, CreateCollectionBuilder, Distance, Filter, PointStruct, ScalarQuantizationBuilder,
3-
SearchParamsBuilder, SearchPointsBuilder, UpsertPointsBuilder, VectorParamsBuilder,
2+
Condition, CreateCollectionBuilder, Distance, Filter, PointStruct, QueryPointsBuilder,
3+
ScalarQuantizationBuilder, SearchParamsBuilder, 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![1.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}");

src/lib.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,37 +86,41 @@
8686
//!
8787
//! Documentation: <https://qdrant.tech/documentation/concepts/points/#upload-points>
8888
//!
89-
//! # Search
89+
//! # Query (search)
9090
//!
9191
//! Finally, we can retrieve points in various ways, the common one being a plain similarity
9292
//! search:
9393
//!
9494
//! ```no_run
9595
//!# use qdrant_client::{Qdrant, QdrantError};
96-
//! use qdrant_client::qdrant::SearchPointsBuilder;
96+
//! use qdrant_client::qdrant::QueryPointsBuilder;
9797
//!
98-
//!# async fn search(client: &Qdrant)
98+
//!# async fn query(client: &Qdrant)
9999
//!# -> Result<(), QdrantError> {
100-
//! let search_request = SearchPointsBuilder::new(
101-
//! "my_collection", // Collection name
102-
//! vec![0.0_f32; 512], // Search vector
103-
//! 4, // Search limit, number of results to return
104-
//! ).with_payload(true);
100+
//! let query_request = QueryPointsBuilder::new("my_collection") // Collection name
101+
//! .query(vec![0.0_f32; 512]) // Query vector
102+
//! .limit(4) // Search limit, number of results to return
103+
//! .with_payload(true); // Include full payload in the result
105104
//!
106-
//! let response = client.search_points(search_request).await?;
105+
//! let response = client.query(query_request).await?;
107106
//!# Ok(())
108107
//!# }
109108
//! ```
110109
//!
111-
//! The parameter for [`SearchPointsBuilder::new()`](qdrant::SearchPointsBuilder::new) constructor
112-
//! are pretty straightforward: name of the collection, the vector and how many top-k results to
113-
//! return. The [`with_payload(true)`](qdrant::SearchPointsBuilder::with_payload) call tells qdrant
114-
//! to also return the (full) payload data for each point. You can also add a
115-
//! [`filter()`](qdrant::SearchPointsBuilder::filter) call to the
116-
//! [`SearchPointsBuilder`](qdrant::SearchPointsBuilder) to filter the result. See the
117-
//! [`Filter`](qdrant::Filter) documentation for details.
110+
//! The parameter for [`QueryPointsBuilder::new()`](qdrant::QueryPointsBuilder::new) is pretty
111+
//! straightforward: the name of the collection to query in. It is combined with other
112+
//! [functions](qdrant::QueryPointsBuilder#implementations) to further specialize your query to
113+
//! cover all query flavors.
118114
//!
119-
//! Documentation: <https://qdrant.tech/documentation/concepts/search/>
115+
//! In this example [`query(...)`](qdrant::QueryPointsBuilder::query) is used to enable vector
116+
//! similarity search on the given vector. [`limit(4)`](qdrant::QueryPointsBuilder::limit)
117+
//! specifies we only want up to 4 top-k results. And
118+
//! [`with_payload(true)`](qdrant::QueryPointsBuilder::with_payload) tells Qdrant to also return
119+
//! the (full) payload data for each point. [`filter()`](qdrant::QueryPointsBuilder::filter) is
120+
//! also commonly used to apply payload based filtering. See the [`Filter`](qdrant::Filter)
121+
//! documentation for details.
122+
//!
123+
//! Documentation: <https://qdrant.tech/documentation/concepts/search/#query-api>
120124
121125
#![doc(html_logo_url = "https://qdrant.tech/favicon/android-chrome-192x192.png")]
122126
#![doc(issue_tracker_base_url = "https://github.com/qdrant/rust-client/issues/")]

src/qdrant_client/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ pub type QdrantBuilder = QdrantConfig;
7272
/// - [Collection operations](Self#collection-operations) - manage collections, aliases and cluster configuration
7373
/// - [Point operations](Self#point-operations) - manage points and vectors
7474
/// - [Payload operations](Self#payload-operations) - manage point payloads
75-
/// - [Search operations](Self#search-operations) - search and explore points
76-
/// - [Query operations](Self#query-operations) - query points using universal search
75+
/// - [Query operations](Self#query-operations) - query (search) points using universal search
7776
/// - [Index operations](Self#index-operations) - manage field and payload indices
7877
/// - [Snapshot operations](Self#snapshot-operations) - manage instance or collection snapshots
7978
/// - [Shard key operations](Self#sharding-key-operations) - manage shard keys
@@ -82,7 +81,7 @@ pub type QdrantBuilder = QdrantConfig;
8281
///
8382
/// - [`create_collection`](Self::create_collection) - create a new collection
8483
/// - [`upsert_points`](Self::upsert_points) - insert or update points
85-
/// - [`search_points`](Self::search_points) - search points with similarity search
84+
/// - [`query`](Self::query) - query points with similarity search
8685
#[derive(Clone)]
8786
pub struct Qdrant {
8887
/// Client configuration

src/qdrant_client/search.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ use crate::qdrant_client::{Qdrant, QdrantResult};
88

99
/// # Search operations
1010
///
11+
/// <div class="warning">
12+
/// For searching, please switch to the more fully featured <a href="#query-operations">Query API</a> instead. The search API will be removed in the future.
13+
/// </div>
14+
///
1115
/// Search and explore points.
1216
///
1317
/// Documentation: <https://qdrant.tech/documentation/concepts/search/>

0 commit comments

Comments
 (0)