diff --git a/README.md b/README.md index db1cf32..3747465 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ async fn main() -> Result<()> { let points = vec![PointStruct::new(0, vec![12.; 10], payload)]; client - .upsert_points_blocking(collection_name, points, None) + .upsert_points_blocking(collection_name, None, points, None) .await?; let search_result = client diff --git a/examples/search.rs b/examples/search.rs index 814a1d5..f5aa7ab 100644 --- a/examples/search.rs +++ b/examples/search.rs @@ -58,7 +58,7 @@ async fn main() -> Result<()> { let points = vec![PointStruct::new(0, vec![12.; 10], payload)]; client - .upsert_points_blocking(collection_name, points, None) + .upsert_points_blocking(collection_name, None, points, None) .await?; let search_result = client diff --git a/proto/collections.proto b/proto/collections.proto index 92ccb0e..765ffcb 100644 --- a/proto/collections.proto +++ b/proto/collections.proto @@ -358,14 +358,14 @@ message PayloadSchemaInfo { message CollectionInfo { CollectionStatus status = 1; // operating condition of the collection OptimizerStatus optimizer_status = 2; // status of collection optimizers - uint64 vectors_count = 3; // number of vectors in the collection + optional uint64 vectors_count = 3; // Approximate number of vectors in the collection uint64 segments_count = 4; // Number of independent segments reserved 5; // Deprecated reserved 6; // Deprecated CollectionConfig config = 7; // Configuration map payload_schema = 8; // Collection data types - uint64 points_count = 9; // number of points in the collection - optional uint64 indexed_vectors_count = 10; // number of indexed vectors in the collection. + optional uint64 points_count = 9; // Approximate number of points in the collection + optional uint64 indexed_vectors_count = 10; // Approximate number of indexed vectors in the collection. } message ChangeAliases { diff --git a/src/client.rs b/src/client.rs index 3ea809a..4225dec 100644 --- a/src/client.rs +++ b/src/client.rs @@ -10,25 +10,28 @@ use crate::qdrant::value::Kind; use crate::qdrant::vectors::VectorsOptions; use crate::qdrant::with_payload_selector::SelectorOptions; use crate::qdrant::{ - qdrant_client, with_vectors_selector, AliasOperations, ChangeAliases, ClearPayloadPoints, - CollectionClusterInfoRequest, CollectionClusterInfoResponse, CollectionOperationResponse, - CountPoints, CountResponse, CreateAlias, CreateCollection, CreateFieldIndexCollection, - CreateFullSnapshotRequest, CreateSnapshotRequest, CreateSnapshotResponse, DeleteAlias, + qdrant_client, shard_key, with_vectors_selector, AliasOperations, ChangeAliases, + ClearPayloadPoints, CollectionClusterInfoRequest, CollectionClusterInfoResponse, + CollectionOperationResponse, CountPoints, CountResponse, CreateAlias, CreateCollection, + CreateFieldIndexCollection, CreateFullSnapshotRequest, CreateShardKey, CreateShardKeyRequest, + CreateShardKeyResponse, CreateSnapshotRequest, CreateSnapshotResponse, DeleteAlias, DeleteCollection, DeleteFieldIndexCollection, DeleteFullSnapshotRequest, DeletePayloadPoints, - DeletePointVectors, DeletePoints, DeleteSnapshotRequest, DeleteSnapshotResponse, FieldType, - GetCollectionInfoRequest, GetCollectionInfoResponse, GetPoints, GetResponse, HealthCheckReply, - HealthCheckRequest, ListAliasesRequest, ListAliasesResponse, ListCollectionAliasesRequest, - ListCollectionsRequest, ListCollectionsResponse, ListFullSnapshotsRequest, - ListSnapshotsRequest, ListSnapshotsResponse, ListValue, NamedVectors, OptimizersConfigDiff, - PayloadIncludeSelector, PayloadIndexParams, PointId, PointStruct, PointVectors, PointsIdsList, - PointsOperationResponse, PointsSelector, PointsUpdateOperation, ReadConsistency, - RecommendBatchPoints, RecommendBatchResponse, RecommendGroupsResponse, RecommendPointGroups, - RecommendPoints, RecommendResponse, RenameAlias, ScrollPoints, ScrollResponse, - SearchBatchPoints, SearchBatchResponse, SearchGroupsResponse, SearchPointGroups, SearchPoints, - SearchResponse, SetPayloadPoints, SparseIndices, Struct, UpdateBatchPoints, - UpdateBatchResponse, UpdateCollection, UpdateCollectionClusterSetupRequest, - UpdateCollectionClusterSetupResponse, UpdatePointVectors, UpsertPoints, Value, Vector, Vectors, - VectorsSelector, WithPayloadSelector, WithVectorsSelector, WriteOrdering, + DeletePointVectors, DeletePoints, DeleteShardKey, DeleteShardKeyRequest, + DeleteShardKeyResponse, DeleteSnapshotRequest, DeleteSnapshotResponse, DiscoverBatchPoints, + DiscoverBatchResponse, DiscoverPoints, DiscoverResponse, FieldType, GetCollectionInfoRequest, + GetCollectionInfoResponse, GetPoints, GetResponse, HealthCheckReply, HealthCheckRequest, + ListAliasesRequest, ListAliasesResponse, ListCollectionAliasesRequest, ListCollectionsRequest, + ListCollectionsResponse, ListFullSnapshotsRequest, ListSnapshotsRequest, ListSnapshotsResponse, + ListValue, NamedVectors, OptimizersConfigDiff, PayloadIncludeSelector, PayloadIndexParams, + PointId, PointStruct, PointVectors, PointsIdsList, PointsOperationResponse, PointsSelector, + PointsUpdateOperation, ReadConsistency, RecommendBatchPoints, RecommendBatchResponse, + RecommendGroupsResponse, RecommendPointGroups, RecommendPoints, RecommendResponse, RenameAlias, + ScrollPoints, ScrollResponse, SearchBatchPoints, SearchBatchResponse, SearchGroupsResponse, + SearchPointGroups, SearchPoints, SearchResponse, SetPayloadPoints, ShardKey, ShardKeySelector, + SparseIndices, Struct, UpdateBatchPoints, UpdateBatchResponse, UpdateCollection, + UpdateCollectionClusterSetupRequest, UpdateCollectionClusterSetupResponse, UpdatePointVectors, + UpsertPoints, Value, Vector, Vectors, VectorsSelector, WithPayloadSelector, + WithVectorsSelector, WriteOrdering, }; use anyhow::Result; #[cfg(feature = "serde")] @@ -225,11 +228,18 @@ impl From> for Vector { impl From> for Vector { fn from(tuples: Vec<(u32, f32)>) -> Self { + Self::from(tuples.as_slice()) + } +} + +// Since we construct two new Vec's anyway it's fine to source from a reference +impl From<&[(u32, f32)]> for Vector { + fn from(tuples: &[(u32, f32)]) -> Self { let mut indices = Vec::with_capacity(tuples.len()); let mut values = Vec::with_capacity(tuples.len()); for (i, w) in tuples { - indices.push(i); - values.push(w); + indices.push(*i); + values.push(*w); } Vector { data: values, @@ -274,6 +284,20 @@ impl From>> for Vectors { } } +// Since we construct two new Vec's anyway it's fine to source from a reference +impl From> for Vectors { + fn from(named_vectors: HashMap) -> Self { + Vectors { + vectors_options: Some(VectorsOptions::Vectors(NamedVectors { + vectors: named_vectors + .into_iter() + .map(|(k, v)| (k, v.into())) + .collect(), + })), + } + } +} + impl From> for Vectors { fn from(vector: Vec) -> Self { Vectors { @@ -663,6 +687,58 @@ impl QdrantClient { .await?) } + pub async fn create_shard_key( + &self, + collection_name: impl AsRef, + shard_key: &shard_key::Key, + shards_number: Option, + replication_factor: Option, + placement: &[u64], + ) -> Result { + let collection_name = collection_name.as_ref(); + + Ok(self + .with_collections_client(|mut collection_api| async move { + let result = collection_api + .create_shard_key(CreateShardKeyRequest { + collection_name: collection_name.to_string(), + request: Some(CreateShardKey { + shard_key: Some(ShardKey::from(shard_key.clone())), + shards_number, + replication_factor, + placement: placement.to_vec(), + }), + timeout: None, + }) + .await?; + Ok(result.into_inner()) + }) + .await?) + } + + pub async fn delete_shard_key( + &self, + collection_name: impl AsRef, + shard_key: &shard_key::Key, + ) -> Result { + let collection_name = collection_name.as_ref(); + + Ok(self + .with_collections_client(|mut collection_api| async move { + let result = collection_api + .delete_shard_key(DeleteShardKeyRequest { + collection_name: collection_name.to_string(), + request: Some(DeleteShardKey { + shard_key: Some(ShardKey::from(shard_key.clone())), + }), + timeout: None, + }) + .await?; + Ok(result.into_inner()) + }) + .await?) + } + pub async fn update_collection_cluster_setup( &self, collection_name: impl ToString, @@ -740,11 +816,18 @@ impl QdrantClient { pub async fn upsert_points( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: Vec, ordering: Option, ) -> Result { - self._upsert_points(collection_name, &points, false, ordering) - .await + self._upsert_points( + collection_name, + shard_key_selector, + &points, + false, + ordering, + ) + .await } /// Update or insert points into the collection, wait for completion. @@ -754,10 +837,11 @@ impl QdrantClient { pub async fn upsert_points_blocking( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: Vec, ordering: Option, ) -> Result { - self._upsert_points(collection_name, &points, true, ordering) + self._upsert_points(collection_name, shard_key_selector, &points, true, ordering) .await } @@ -765,6 +849,7 @@ impl QdrantClient { async fn _upsert_points( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &[PointStruct], block: bool, ordering: Option, @@ -772,6 +857,8 @@ impl QdrantClient { let collection_name = collection_name.to_string(); let collection_name_ref = collection_name.as_str(); let ordering_ref = ordering.as_ref(); + let shard_keys = shard_key_selector.map(ShardKeySelector::from); + let shard_keys_ref = &shard_keys; Ok(self .with_points_client(|mut points_api| async move { Ok(points_api @@ -780,7 +867,7 @@ impl QdrantClient { wait: Some(block), points: points.to_vec(), ordering: ordering_ref.cloned(), - shard_key_selector: None, + shard_key_selector: shard_keys_ref.clone(), }) .await? .into_inner()) @@ -795,12 +882,20 @@ impl QdrantClient { pub async fn upsert_points_batch( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: Vec, ordering: Option, chunk_size: usize, ) -> Result { - self._upsert_points_batch(collection_name, &points, false, ordering, chunk_size) - .await + self._upsert_points_batch( + collection_name, + shard_key_selector, + &points, + false, + ordering, + chunk_size, + ) + .await } /// Update or insert points into the collection, splitting in chunks and @@ -809,18 +904,27 @@ impl QdrantClient { pub async fn upsert_points_batch_blocking( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: Vec, ordering: Option, chunk_size: usize, ) -> Result { - self._upsert_points_batch(collection_name, &points, true, ordering, chunk_size) - .await + self._upsert_points_batch( + collection_name, + shard_key_selector, + &points, + true, + ordering, + chunk_size, + ) + .await } #[inline] async fn _upsert_points_batch( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &[PointStruct], block: bool, ordering: Option, @@ -828,12 +932,14 @@ impl QdrantClient { ) -> Result { if points.len() < chunk_size { return self - ._upsert_points(collection_name, points, block, ordering) + ._upsert_points(collection_name, shard_key_selector, points, block, ordering) .await; } let collection_name = collection_name.to_string(); let collection_name_ref = collection_name.as_str(); let ordering_ref = ordering.as_ref(); + let shard_keys = shard_key_selector.map(ShardKeySelector::from); + let shard_keys_ref = &shard_keys; Ok(self .with_points_client(|mut points_api| async move { let mut resp = PointsOperationResponse { @@ -847,7 +953,7 @@ impl QdrantClient { wait: Some(block), points: chunk.to_vec(), ordering: ordering_ref.cloned(), - shard_key_selector: None, + shard_key_selector: shard_keys_ref.clone(), }) .await? .into_inner(); @@ -862,29 +968,46 @@ impl QdrantClient { pub async fn set_payload( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &PointsSelector, payload: Payload, ordering: Option, ) -> Result { - self._set_payload(collection_name, points, &payload, false, ordering) - .await + self._set_payload( + collection_name, + shard_key_selector, + points, + &payload, + false, + ordering, + ) + .await } pub async fn set_payload_blocking( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &PointsSelector, payload: Payload, ordering: Option, ) -> Result { - self._set_payload(collection_name, points, &payload, true, ordering) - .await + self._set_payload( + collection_name, + shard_key_selector, + points, + &payload, + true, + ordering, + ) + .await } #[inline] async fn _set_payload( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &PointsSelector, payload: &Payload, block: bool, @@ -893,6 +1016,8 @@ impl QdrantClient { let collection_name = collection_name.to_string(); let collection_name_ref = collection_name.as_str(); let ordering_ref = ordering.as_ref(); + let shard_keys = shard_key_selector.map(ShardKeySelector::from); + let shard_keys_ref = &shard_keys; Ok(self .with_points_client(|mut points_api| async move { @@ -903,7 +1028,7 @@ impl QdrantClient { payload: payload.0.clone(), points_selector: Some(points.clone()), ordering: ordering_ref.cloned(), - shard_key_selector: None, + shard_key_selector: shard_keys_ref.clone(), }) .await?; Ok(result.into_inner()) @@ -914,29 +1039,46 @@ impl QdrantClient { pub async fn overwrite_payload( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &PointsSelector, payload: Payload, ordering: Option, ) -> Result { - self._overwrite_payload(collection_name, points, &payload, false, ordering) - .await + self._overwrite_payload( + collection_name, + shard_key_selector, + points, + &payload, + false, + ordering, + ) + .await } pub async fn overwrite_payload_blocking( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &PointsSelector, payload: Payload, ordering: Option, ) -> Result { - self._overwrite_payload(collection_name, points, &payload, true, ordering) - .await + self._overwrite_payload( + collection_name, + shard_key_selector, + points, + &payload, + true, + ordering, + ) + .await } #[inline] async fn _overwrite_payload( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &PointsSelector, payload: &Payload, block: bool, @@ -945,6 +1087,8 @@ impl QdrantClient { let collection_name = collection_name.to_string(); let collection_name_ref = collection_name.as_str(); let ordering_ref = ordering.as_ref(); + let shard_keys = shard_key_selector.map(ShardKeySelector::from); + let shard_keys_ref = &shard_keys; Ok(self .with_points_client(|mut points_api| async move { @@ -955,7 +1099,7 @@ impl QdrantClient { payload: payload.0.clone(), points_selector: Some(points.clone()), ordering: ordering_ref.cloned(), - shard_key_selector: None, + shard_key_selector: shard_keys_ref.clone(), }) .await?; Ok(result.into_inner()) @@ -966,29 +1110,46 @@ impl QdrantClient { pub async fn delete_payload( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &PointsSelector, keys: Vec, ordering: Option, ) -> Result { - self._delete_payload(collection_name, points, &keys, false, ordering) - .await + self._delete_payload( + collection_name, + shard_key_selector, + points, + &keys, + false, + ordering, + ) + .await } pub async fn delete_payload_blocking( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &PointsSelector, keys: Vec, ordering: Option, ) -> Result { - self._delete_payload(collection_name, points, &keys, true, ordering) - .await + self._delete_payload( + collection_name, + shard_key_selector, + points, + &keys, + true, + ordering, + ) + .await } #[inline] async fn _delete_payload( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &PointsSelector, keys: &[String], block: bool, @@ -997,6 +1158,8 @@ impl QdrantClient { let collection_name = collection_name.to_string(); let collection_name_ref = collection_name.as_str(); let ordering_ref = ordering.as_ref(); + let shard_keys = shard_key_selector.map(ShardKeySelector::from); + let shard_keys_ref = &shard_keys; Ok(self .with_points_client(|mut points_api| async move { @@ -1007,7 +1170,7 @@ impl QdrantClient { keys: keys.to_owned(), points_selector: Some(points.clone()), ordering: ordering_ref.cloned(), - shard_key_selector: None, + shard_key_selector: shard_keys_ref.clone(), }) .await?; Ok(result.into_inner()) @@ -1018,27 +1181,42 @@ impl QdrantClient { pub async fn clear_payload( &self, collection_name: impl ToString, + shard_key_selector: Option>, points_selector: Option, ordering: Option, ) -> Result { - self._clear_payload(collection_name, points_selector.as_ref(), false, ordering) - .await + self._clear_payload( + collection_name, + shard_key_selector, + points_selector.as_ref(), + false, + ordering, + ) + .await } pub async fn clear_payload_blocking( &self, collection_name: impl ToString, + shard_key_selector: Option>, points_selector: Option, ordering: Option, ) -> Result { - self._clear_payload(collection_name, points_selector.as_ref(), true, ordering) - .await + self._clear_payload( + collection_name, + shard_key_selector, + points_selector.as_ref(), + true, + ordering, + ) + .await } #[inline] async fn _clear_payload( &self, collection_name: impl ToString, + shard_key_selector: Option>, points_selector: Option<&PointsSelector>, block: bool, ordering: Option, @@ -1046,6 +1224,8 @@ impl QdrantClient { let collection_name = collection_name.to_string(); let collection_name_ref = collection_name.as_str(); let ordering_ref = ordering.as_ref(); + let shard_keys = shard_key_selector.map(ShardKeySelector::from); + let shard_keys_ref = &shard_keys; Ok(self .with_points_client(|mut points_api| async move { @@ -1055,7 +1235,7 @@ impl QdrantClient { wait: Some(block), points: points_selector.cloned(), ordering: ordering_ref.cloned(), - shard_key_selector: None, + shard_key_selector: shard_keys_ref.clone(), }) .await?; Ok(result.into_inner()) @@ -1066,6 +1246,7 @@ impl QdrantClient { pub async fn get_points( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &[PointId], with_vectors: Option>, with_payload: Option>, @@ -1081,6 +1262,9 @@ impl QdrantClient { let with_payload_ref = with_payload.as_ref(); let read_consistency_ref = read_consistency.as_ref(); + let shard_keys = shard_key_selector.map(ShardKeySelector::from); + let shard_keys_ref = &shard_keys; + Ok(self .with_points_client(|mut points_api| async move { let result = points_api @@ -1090,7 +1274,7 @@ impl QdrantClient { with_payload: with_payload_ref.cloned(), with_vectors: with_vectors_ref.cloned(), read_consistency: read_consistency_ref.cloned(), - shard_key_selector: None, + shard_key_selector: shard_keys_ref.clone(), }) .await?; @@ -1132,26 +1316,29 @@ impl QdrantClient { pub async fn delete_points( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &PointsSelector, ordering: Option, ) -> Result { - self._delete_points(collection_name, false, points, ordering) + self._delete_points(collection_name, shard_key_selector, false, points, ordering) .await } pub async fn delete_points_blocking( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &PointsSelector, ordering: Option, ) -> Result { - self._delete_points(collection_name, true, points, ordering) + self._delete_points(collection_name, shard_key_selector, true, points, ordering) .await } async fn _delete_points( &self, collection_name: impl ToString, + shard_key_selector: Option>, blocking: bool, points: &PointsSelector, ordering: Option, @@ -1159,6 +1346,8 @@ impl QdrantClient { let collection_name = collection_name.to_string(); let collection_name_ref = collection_name.as_str(); let ordering_ref = ordering.as_ref(); + let shard_keys = shard_key_selector.map(ShardKeySelector::from); + let shard_keys_ref = &shard_keys; Ok(self .with_points_client(|mut points_api| async move { @@ -1168,7 +1357,7 @@ impl QdrantClient { wait: Some(blocking), points: Some(points.clone()), ordering: ordering_ref.cloned(), - shard_key_selector: None, + shard_key_selector: shard_keys_ref.clone(), }) .await?; Ok(result.into_inner()) @@ -1179,12 +1368,14 @@ impl QdrantClient { pub async fn delete_vectors( &self, collection_name: impl ToString, + shard_key_selector: Option>, points_selector: &PointsSelector, vector_selector: &VectorsSelector, ordering: Option, ) -> Result { self._delete_vectors( collection_name, + shard_key_selector, false, points_selector, vector_selector, @@ -1196,12 +1387,14 @@ impl QdrantClient { pub async fn delete_vectors_blocking( &self, collection_name: impl ToString, + shard_key_selector: Option>, points_selector: &PointsSelector, vector_selector: &VectorsSelector, ordering: Option, ) -> Result { self._delete_vectors( collection_name, + shard_key_selector, true, points_selector, vector_selector, @@ -1213,6 +1406,7 @@ impl QdrantClient { async fn _delete_vectors( &self, collection_name: impl ToString, + shard_key_selector: Option>, blocking: bool, points_selector: &PointsSelector, vector_selector: &VectorsSelector, @@ -1221,6 +1415,8 @@ impl QdrantClient { let collection_name = collection_name.to_string(); let collection_name_ref = collection_name.as_str(); let ordering_ref = ordering.as_ref(); + let shard_keys = shard_key_selector.map(ShardKeySelector::from); + let shard_keys_ref = &shard_keys; Ok(self .with_points_client(|mut points_api| async move { @@ -1231,7 +1427,7 @@ impl QdrantClient { points_selector: Some(points_selector.clone()), vectors: Some(vector_selector.clone()), ordering: ordering_ref.cloned(), - shard_key_selector: None, + shard_key_selector: shard_keys_ref.clone(), }) .await?; Ok(result.into_inner()) @@ -1242,26 +1438,29 @@ impl QdrantClient { pub async fn update_vectors( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &[PointVectors], ordering: Option, ) -> Result { - self._update_vectors(collection_name, false, points, ordering) + self._update_vectors(collection_name, shard_key_selector, false, points, ordering) .await } pub async fn update_vectors_blocking( &self, collection_name: impl ToString, + shard_key_selector: Option>, points: &[PointVectors], ordering: Option, ) -> Result { - self._update_vectors(collection_name, true, points, ordering) + self._update_vectors(collection_name, shard_key_selector, true, points, ordering) .await } async fn _update_vectors( &self, collection_name: impl ToString, + shard_key_selector: Option>, blocking: bool, points: &[PointVectors], ordering: Option, @@ -1269,6 +1468,8 @@ impl QdrantClient { let collection_name = collection_name.to_string(); let collection_name_ref = collection_name.as_str(); let ordering_ref = ordering.as_ref(); + let shard_keys = shard_key_selector.map(ShardKeySelector::from); + let shard_keys_ref = &shard_keys; Ok(self .with_points_client(|mut points_api| async move { @@ -1278,7 +1479,7 @@ impl QdrantClient { wait: Some(blocking), points: points.to_owned(), ordering: ordering_ref.cloned(), - shard_key_selector: None, + shard_key_selector: shard_keys_ref.clone(), }) .await?; Ok(result.into_inner()) @@ -1328,6 +1529,27 @@ impl QdrantClient { .await?) } + pub async fn discover(&self, request: &DiscoverPoints) -> Result { + Ok(self + .with_points_client(|mut points_api| async move { + let result = points_api.discover(request.clone()).await?; + Ok(result.into_inner()) + }) + .await?) + } + + pub async fn discover_batch( + &self, + request: &DiscoverBatchPoints, + ) -> Result { + Ok(self + .with_points_client(|mut points_api| async move { + let result = points_api.discover_batch(request.clone()).await?; + Ok(result.into_inner()) + }) + .await?) + } + pub async fn count(&self, request: &CountPoints) -> Result { Ok(self .with_points_client(|mut points_api| async move { @@ -1798,3 +2020,53 @@ where } } } + +impl From for ShardKey { + fn from(key: shard_key::Key) -> Self { + ShardKey { key: Some(key) } + } +} + +impl From> for ShardKeySelector { + fn from(shard_keys: Vec) -> Self { + ShardKeySelector { + shard_keys: shard_keys.into_iter().map(ShardKey::from).collect(), + } + } +} + +impl From for shard_key::Key { + fn from(keyword: String) -> Self { + shard_key::Key::Keyword(keyword) + } +} + +impl From for shard_key::Key { + fn from(number: u64) -> Self { + shard_key::Key::Number(number) + } +} + +impl From for ShardKeySelector { + fn from(keyword: String) -> Self { + keyword.into() + } +} + +impl From for ShardKeySelector { + fn from(number: u64) -> Self { + number.into() + } +} + +impl From> for ShardKeySelector { + fn from(keywords: Vec) -> Self { + keywords.into() + } +} + +impl From> for ShardKeySelector { + fn from(numbers: Vec) -> Self { + numbers.into() + } +} diff --git a/src/lib.rs b/src/lib.rs index 700eb56..89432b6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,7 +72,7 @@ //! }; //! //! let response = qdrant_client -//! .upsert_points("my_collection", vec![point], None) +//! .upsert_points("my_collection", None, vec![point], None) //! .await?; //!# Ok(()) //!# } @@ -504,7 +504,7 @@ mod tests { let points = vec![PointStruct::new(0, vec![12.; 10], payload)]; client - .upsert_points_blocking(collection_name, points, None) + .upsert_points_blocking(collection_name, None, points, None) .await?; let search_result = client @@ -534,13 +534,20 @@ mod tests { .collect::>() .into(); client - .set_payload(collection_name, &vec![0.into()].into(), new_payload, None) + .set_payload( + collection_name, + None, + &vec![0.into()].into(), + new_payload, + None, + ) .await?; // Delete some payload fields client .delete_payload_blocking( collection_name, + None, &vec![0.into()].into(), vec!["sub_payload".to_string()], None, @@ -549,7 +556,14 @@ mod tests { // retrieve points let points = client - .get_points(collection_name, &[0.into()], Some(true), Some(true), None) + .get_points( + collection_name, + None, + &[0.into()], + Some(true), + Some(true), + None, + ) .await?; assert_eq!(points.result.len(), 1); @@ -558,7 +572,7 @@ mod tests { assert!(!point.payload.contains_key("sub_payload")); client - .delete_points(collection_name, &vec![0.into()].into(), None) + .delete_points(collection_name, None, &vec![0.into()].into(), None) .await?; // Access raw point api with client diff --git a/src/qdrant.rs b/src/qdrant.rs index 077121d..9c8d020 100644 --- a/src/qdrant.rs +++ b/src/qdrant.rs @@ -539,9 +539,9 @@ pub struct CollectionInfo { /// status of collection optimizers #[prost(message, optional, tag = "2")] pub optimizer_status: ::core::option::Option, - /// number of vectors in the collection - #[prost(uint64, tag = "3")] - pub vectors_count: u64, + /// Approximate number of vectors in the collection + #[prost(uint64, optional, tag = "3")] + pub vectors_count: ::core::option::Option, /// Number of independent segments #[prost(uint64, tag = "4")] pub segments_count: u64, @@ -554,10 +554,10 @@ pub struct CollectionInfo { ::prost::alloc::string::String, PayloadSchemaInfo, >, - /// number of points in the collection - #[prost(uint64, tag = "9")] - pub points_count: u64, - /// number of indexed vectors in the collection. + /// Approximate number of points in the collection + #[prost(uint64, optional, tag = "9")] + pub points_count: ::core::option::Option, + /// Approximate number of indexed vectors in the collection. #[prost(uint64, optional, tag = "10")] pub indexed_vectors_count: ::core::option::Option, }