Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes related to the next Meilisearch release (v1.7.0) #544

Merged
merged 3 commits into from
Mar 11, 2024
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
1 change: 0 additions & 1 deletion .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,6 @@ get_experimental_features_1: |-
update_experimental_features_1: |-
let client = Client::new("http://localhost:7700", Some("apiKey"));
let mut features = ExperimentalFeatures::new(&client);
features.set_score_details(true);
features.set_vector_store(true);
let res = features
.update()
Expand Down
25 changes: 2 additions & 23 deletions src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExperimentalFeaturesResult {
pub score_details: bool,
pub vector_store: bool,
}

Expand All @@ -24,33 +23,25 @@ pub struct ExperimentalFeaturesResult {
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
/// # let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY));
/// let mut features = ExperimentalFeatures::new(&client);
/// features.set_score_details(true);
/// features.set_vector_store(true);
/// ```
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ExperimentalFeatures<'a> {
#[serde(skip_serializing)]
client: &'a Client,
#[serde(skip_serializing_if = "Option::is_none")]
pub score_details: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub vector_store: Option<bool>,
}

impl<'a> ExperimentalFeatures<'a> {
pub fn new(client: &'a Client) -> Self {
ExperimentalFeatures {
client,
score_details: None,
vector_store: None,
}
}

pub fn set_score_details(&mut self, score_details: bool) -> &mut Self {
self.score_details = Some(score_details);
self
}

pub fn set_vector_store(&mut self, vector_store: bool) -> &mut Self {
self.vector_store = Some(vector_store);
self
Expand Down Expand Up @@ -91,7 +82,7 @@ impl<'a> ExperimentalFeatures<'a> {
/// # let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY));
/// futures::executor::block_on(async move {
/// let mut features = ExperimentalFeatures::new(&client);
/// features.set_score_details(true);
/// features.set_vector_store(true);
/// features.update().await.unwrap();
/// });
/// ```
Expand All @@ -117,26 +108,14 @@ mod tests {
#[meilisearch_test]
async fn test_experimental_features_get(client: Client) {
let mut features = ExperimentalFeatures::new(&client);
features.set_score_details(false);
features.set_vector_store(false);
let _ = features.update().await.unwrap();

let res = features.get().await.unwrap();

assert!(!res.score_details);
assert!(!res.vector_store);
}

#[meilisearch_test]
async fn test_experimental_features_enable_score_details(client: Client) {
let mut features = ExperimentalFeatures::new(&client);
features.set_score_details(true);

let res = features.update().await.unwrap();

assert!(res.score_details);
}

#[meilisearch_test]
async fn test_experimental_features_enable_vector_store(client: Client) {
let mut features = ExperimentalFeatures::new(&client);
Expand Down
Loading