You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Problem
One of the parameters for `fetch` was `&[String]` instead of `&[&str]`.
Similarly, one of the parameters for `query_by_id` was `String` instead
of `&str`.
## Solution
I changed the parameter types to `&[&str]` and `&str` respectively for
consistency with other functions. I also updated all relevant code.
## Type of Change
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Infrastructure change (CI configs, etc)
- [ ] Non-code change (docs, etc)
- [ ] None of the above: (explain here)
## Test Plan
Test cases should pass.
Copy file name to clipboardExpand all lines: pinecone_sdk/src/pinecone/data.rs
+9-8
Original file line number
Diff line number
Diff line change
@@ -293,7 +293,7 @@ impl Index {
293
293
/// The query operation searches a namespace using a query vector. It retrieves the ids of the most similar items in a namespace, along with their similarity scores.
294
294
///
295
295
/// ### Arguments
296
-
/// * `id: String` - The id of the query vector.
296
+
/// * `id: &str` - The id of the query vector.
297
297
/// * `top_k: u32` - The number of results to return.
298
298
/// * `namespace: &Namespace` - The namespace to query. Default is "".
299
299
/// * `filter: Option<Metadata>` - The filter to apply to limit your search by vector metadata.
@@ -317,21 +317,21 @@ impl Index {
317
317
/// let mut index = pinecone.index("index-host").await.unwrap();
318
318
///
319
319
/// // Query the vector with id "vector-id" in the namespace "namespace"
320
-
/// let response = index.query_by_id("vector-id".to_string(), 10, &Namespace::default(), None, None, None).await.unwrap();
320
+
/// let response = index.query_by_id("vector-id", 10, &Namespace::default(), None, None, None).await.unwrap();
321
321
/// # Ok(())
322
322
/// # }
323
323
/// ```
324
324
pubasyncfnquery_by_id(
325
325
&mutself,
326
-
id:String,
326
+
id:&str,
327
327
top_k:u32,
328
328
namespace:&Namespace,
329
329
filter:Option<Metadata>,
330
330
include_values:Option<bool>,
331
331
include_metadata:Option<bool>,
332
332
) -> Result<QueryResponse,PineconeError>{
333
333
let request = pb::QueryRequest{
334
-
id,
334
+
id: id.to_string(),
335
335
top_k,
336
336
namespace: namespace.name.clone(),
337
337
filter,
@@ -547,7 +547,7 @@ impl Index {
547
547
/// The fetch operation retrieves vectors by ID from a namespace.
548
548
///
549
549
/// ### Arguments
550
-
/// * `ids: &[String]` - The ids of vectors to fetch.
550
+
/// * `ids: &[&str]` - The ids of vectors to fetch.
551
551
/// * `namespace: &Namespace` - The namespace to fetch vectors from. Default is "".
552
552
///
553
553
/// ### Return
@@ -567,7 +567,7 @@ impl Index {
567
567
/// // Connect to index host url
568
568
/// let mut index = pinecone.index("index-host").await.unwrap();
569
569
///
570
-
/// let vectors = &["1".to_string(), "2".to_string()];
570
+
/// let vectors = &["1", "2"];
571
571
///
572
572
/// // Fetch vectors from the default namespace that have the ids in the list
573
573
/// let response = index.fetch(vectors, &Default::default()).await.unwrap();
@@ -576,11 +576,12 @@ impl Index {
576
576
/// ```
577
577
pubasyncfnfetch(
578
578
&mutself,
579
-
ids:&[String],
579
+
ids:&[&str],
580
580
namespace:&Namespace,
581
581
) -> Result<FetchResponse,PineconeError>{
582
+
let ids = ids.iter().map(|id| id.to_string()).collect::<Vec<String>>();
0 commit comments