Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/builders/create_shard_key_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CreateShardKey, std::convert::Infallible> {
Ok(CreateShardKey {
shard_key: self.shard_key.unwrap_or_default(),
Expand Down
4 changes: 3 additions & 1 deletion tests/snippet_tests/test_create_shard_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand All @@ -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?;
Expand Down
4 changes: 3 additions & 1 deletion tests/snippets/create_shard_key.rs
Original file line number Diff line number Diff line change
@@ -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()?;
Expand All @@ -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?;