From 84a5c304fc78d85652897182cc66a85a454c0579 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 11 Jan 2024 21:35:06 +0100 Subject: [PATCH 1/2] Don't display the embedders setting when it is an empty dict --- meilisearch-types/src/settings.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/meilisearch-types/src/settings.rs b/meilisearch-types/src/settings.rs index 9613cb9f3..ca46abb0c 100644 --- a/meilisearch-types/src/settings.rs +++ b/meilisearch-types/src/settings.rs @@ -600,11 +600,12 @@ pub fn settings( ), }; - let embedders = index + let embedders: BTreeMap<_, _> = index .embedding_configs(rtxn)? .into_iter() .map(|(name, config)| (name, Setting::Set(config.into()))) .collect(); + let embedders = if embedders.is_empty() { Setting::NotSet } else { Setting::Set(embedders) }; Ok(Settings { displayed_attributes: match displayed_attributes { @@ -631,7 +632,7 @@ pub fn settings( typo_tolerance: Setting::Set(typo_tolerance), faceting: Setting::Set(faceting), pagination: Setting::Set(pagination), - embedders: Setting::Set(embedders), + embedders, _kind: PhantomData, }) } From 38abfec611142ae97e54932a9238b6941032ac0b Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 11 Jan 2024 21:35:30 +0100 Subject: [PATCH 2/2] Fix tests --- meilisearch/tests/dumps/mod.rs | 39 ++++++++-------------- meilisearch/tests/settings/get_settings.rs | 3 +- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/meilisearch/tests/dumps/mod.rs b/meilisearch/tests/dumps/mod.rs index 90b9b91da..fd34268a5 100644 --- a/meilisearch/tests/dumps/mod.rs +++ b/meilisearch/tests/dumps/mod.rs @@ -77,8 +77,7 @@ async fn import_dump_v1_movie_raw() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -239,8 +238,7 @@ async fn import_dump_v1_movie_with_settings() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -387,8 +385,7 @@ async fn import_dump_v1_rubygems_with_settings() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -521,8 +518,7 @@ async fn import_dump_v2_movie_raw() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -667,8 +663,7 @@ async fn import_dump_v2_movie_with_settings() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -812,8 +807,7 @@ async fn import_dump_v2_rubygems_with_settings() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -946,8 +940,7 @@ async fn import_dump_v3_movie_raw() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -1092,8 +1085,7 @@ async fn import_dump_v3_movie_with_settings() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -1237,8 +1229,7 @@ async fn import_dump_v3_rubygems_with_settings() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -1371,8 +1362,7 @@ async fn import_dump_v4_movie_raw() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -1517,8 +1507,7 @@ async fn import_dump_v4_movie_with_settings() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -1662,8 +1651,7 @@ async fn import_dump_v4_rubygems_with_settings() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "### ); @@ -1907,8 +1895,7 @@ async fn import_dump_v6_containing_experimental_features() { }, "pagination": { "maxTotalHits": 1000 - }, - "embedders": {} + } } "###); diff --git a/meilisearch/tests/settings/get_settings.rs b/meilisearch/tests/settings/get_settings.rs index 79689c1b5..5642e854f 100644 --- a/meilisearch/tests/settings/get_settings.rs +++ b/meilisearch/tests/settings/get_settings.rs @@ -54,7 +54,7 @@ async fn get_settings() { let (response, code) = index.settings().await; assert_eq!(code, 200); let settings = response.as_object().unwrap(); - assert_eq!(settings.keys().len(), 16); + assert_eq!(settings.keys().len(), 15); assert_eq!(settings["displayedAttributes"], json!(["*"])); assert_eq!(settings["searchableAttributes"], json!(["*"])); assert_eq!(settings["filterableAttributes"], json!([])); @@ -83,7 +83,6 @@ async fn get_settings() { "maxTotalHits": 1000, }) ); - assert_eq!(settings["embedders"], json!({})); assert_eq!(settings["proximityPrecision"], json!("byWord")); }