diff --git a/src/builders/create_shard_key_builder.rs b/src/builders/create_shard_key_builder.rs index fc09c9b..ccf2f7e 100644 --- a/src/builders/create_shard_key_builder.rs +++ b/src/builders/create_shard_key_builder.rs @@ -51,11 +51,12 @@ impl CreateShardKeyBuilder { /// /// Use with caution! Setting arbirray replica states here may break your Qdrant cluster. #[allow(unused_mut)] - pub fn initial_state(self, value: i32) -> Self { + pub fn initial_state(self, value: ReplicaState) -> Self { let mut new = self; - new.initial_state = Option::Some(Option::Some(value)); + new.initial_state = Option::Some(Option::Some(value as i32)); new } + fn build_inner(self) -> Result { Ok(CreateShardKey { shard_key: self.shard_key.unwrap_or_default(), diff --git a/tests/snippet_tests/test_create_shard_key.rs b/tests/snippet_tests/test_create_shard_key.rs index 52fcc84..14f9a8e 100644 --- a/tests/snippet_tests/test_create_shard_key.rs +++ b/tests/snippet_tests/test_create_shard_key.rs @@ -6,6 +6,7 @@ async fn test_create_shard_key() { // Please, modify the snippet in the `../snippets/create_shard_key.rs` file use qdrant_client::qdrant::shard_key::Key; use qdrant_client::qdrant::{CreateShardKeyBuilder, CreateShardKeyRequestBuilder}; + use qdrant_client::qdrant::ReplicaState; use qdrant_client::Qdrant; let client = Qdrant::from_url("http://localhost:6334").build()?; @@ -14,7 +15,8 @@ async fn test_create_shard_key() { .create_shard_key( CreateShardKeyRequestBuilder::new("{collection_name}").request( CreateShardKeyBuilder::default() - .shard_key(Key::Keyword("{shard_key}".to_string())), + .shard_key(Key::Keyword("{shard_key}".to_string())) + .initial_state(ReplicaState::Active), ), ) .await?; diff --git a/tests/snippets/create_shard_key.rs b/tests/snippets/create_shard_key.rs index 2b4ce63..6559eb7 100644 --- a/tests/snippets/create_shard_key.rs +++ b/tests/snippets/create_shard_key.rs @@ -1,5 +1,6 @@ use qdrant_client::qdrant::shard_key::Key; use qdrant_client::qdrant::{CreateShardKeyBuilder, CreateShardKeyRequestBuilder}; +use qdrant_client::qdrant::ReplicaState; use qdrant_client::Qdrant; let client = Qdrant::from_url("http://localhost:6334").build()?; @@ -8,7 +9,8 @@ client .create_shard_key( CreateShardKeyRequestBuilder::new("{collection_name}").request( CreateShardKeyBuilder::default() - .shard_key(Key::Keyword("{shard_key}".to_string())), + .shard_key(Key::Keyword("{shard_key}".to_string())) + .initial_state(ReplicaState::Active), ), ) .await?;