-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Organize client operations, split into modules, order by CRUD (#152)
* Separate client operations in categories, link to them * Reorder client functions, follow CRUD principles * Extract search operations into search module * Extract index operations into index module * Extract payload operations into payload module * Add construct and connect header
- Loading branch information
Showing
9 changed files
with
956 additions
and
911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
use crate::qdrant::{ | ||
CreateFieldIndexCollection, DeleteFieldIndexCollection, PointsOperationResponse, | ||
}; | ||
use crate::qdrant_client::{Qdrant, QdrantResult}; | ||
|
||
/// # Index operations | ||
/// | ||
/// Manage field and payload indices in collections. | ||
/// | ||
/// Documentation: <https://qdrant.tech/documentation/concepts/indexing/> | ||
impl Qdrant { | ||
/// Create payload index in a collection. | ||
/// | ||
/// ```no_run | ||
///# use std::collections::HashMap; | ||
///# use qdrant_client::{Qdrant, QdrantError}; | ||
/// use qdrant_client::qdrant::{CreateFieldIndexCollectionBuilder, FieldType}; | ||
/// | ||
///# async fn create_field_index(client: &Qdrant) | ||
///# -> Result<(), QdrantError> { | ||
/// client | ||
/// .create_field_index( | ||
/// CreateFieldIndexCollectionBuilder::new( | ||
/// "my_collection", | ||
/// "city", | ||
/// FieldType::Keyword, | ||
/// ), | ||
/// ) | ||
/// .await?; | ||
///# Ok(()) | ||
///# } | ||
/// ``` | ||
/// | ||
/// Documentation: <https://qdrant.tech/documentation/concepts/indexing/#payload-index> | ||
pub async fn create_field_index( | ||
&self, | ||
request: impl Into<CreateFieldIndexCollection>, | ||
) -> QdrantResult<PointsOperationResponse> { | ||
let request = &request.into(); | ||
|
||
self.with_points_client(|mut client| async move { | ||
let result = client.create_field_index(request.clone()).await?; | ||
Ok(result.into_inner()) | ||
}) | ||
.await | ||
} | ||
|
||
/// Delete payload index from a collection. | ||
/// | ||
/// ```no_run | ||
///# use std::collections::HashMap; | ||
///# use qdrant_client::{Qdrant, QdrantError}; | ||
/// use qdrant_client::qdrant::DeleteFieldIndexCollectionBuilder; | ||
/// | ||
///# async fn create_field_index(client: &Qdrant) | ||
///# -> Result<(), QdrantError> { | ||
/// client | ||
/// .delete_field_index(DeleteFieldIndexCollectionBuilder::new( | ||
/// "my_collection", | ||
/// "city", | ||
/// )) | ||
/// .await?; | ||
///# Ok(()) | ||
///# } | ||
/// ``` | ||
/// | ||
/// Documentation: <https://qdrant.tech/documentation/concepts/indexing/#payload-index> | ||
pub async fn delete_field_index( | ||
&self, | ||
request: impl Into<DeleteFieldIndexCollection>, | ||
) -> QdrantResult<PointsOperationResponse> { | ||
let request = &request.into(); | ||
|
||
self.with_points_client(|mut client| async move { | ||
let result = client.delete_field_index(request.clone()).await?; | ||
Ok(result.into_inner()) | ||
}) | ||
.await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.