From 3084537d1ed03625b767ad792a266de0f8c616e1 Mon Sep 17 00:00:00 2001 From: mpostma Date: Wed, 4 Aug 2021 10:33:30 +0200 Subject: [PATCH 1/4] restore attributes for faceting in dump v1 --- .../src/index_controller/dump_actor/loaders/v1.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs b/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs index c631e113c..c0c7b8ef2 100644 --- a/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs +++ b/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs @@ -73,7 +73,7 @@ struct Settings { #[serde(default, deserialize_with = "deserialize_some")] pub synonyms: Option>>>, #[serde(default, deserialize_with = "deserialize_some")] - pub filterable_attributes: Option>>, + pub attributes_for_faceting: Option>>, } fn load_index( @@ -142,7 +142,7 @@ impl From for index_controller::Settings { // representing the name of the faceted field + the type of the field. Since the type // was not known in the V1 of the dump we are just going to assume everything is a // String - filterable_attributes: settings.filterable_attributes.map(|o| o.map(|vec| vec.into_iter().collect())), + filterable_attributes: settings.attributes_for_faceting.map(|o| o.map(|vec| vec.into_iter().collect())), // we need to convert the old `Vec` into a `BTreeSet` ranking_rules: settings.ranking_rules.map(|o| o.map(|vec| vec.into_iter().filter_map(|criterion| { match criterion.as_str() { From 29ca8271b36d73e061fdebbb271a8e38d6ca0063 Mon Sep 17 00:00:00 2001 From: mpostma Date: Wed, 4 Aug 2021 11:02:17 +0200 Subject: [PATCH 2/4] test dumpv1 format regression --- .../src/index_controller/dump_actor/loaders/v1.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs b/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs index c0c7b8ef2..c19ba4329 100644 --- a/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs +++ b/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs @@ -180,3 +180,17 @@ fn import_settings(dir_path: impl AsRef) -> anyhow::Result { Ok(metadata) } + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn settings_format_regression() { + let settings = Settings::default(); + assert_eq!( + r##"{"rankingRules":null,"distinctAttribute":null,"searchableAttributes":null,"displayedAttributes":null,"stopWords":null,"synonyms":null,"attributesForFaceting":null}"##, + serde_json::to_string(&settings).unwrap() + ); + } +} From f5ddea481aebcfc966760b6fcf4bb89e3979796b Mon Sep 17 00:00:00 2001 From: mpostma Date: Wed, 4 Aug 2021 14:40:08 +0200 Subject: [PATCH 3/4] reintroduce exactness --- .../src/index_controller/dump_actor/loaders/v1.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs b/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs index c19ba4329..034e464b1 100644 --- a/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs +++ b/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs @@ -146,14 +146,10 @@ impl From for index_controller::Settings { // we need to convert the old `Vec` into a `BTreeSet` ranking_rules: settings.ranking_rules.map(|o| o.map(|vec| vec.into_iter().filter_map(|criterion| { match criterion.as_str() { - "words" | "typo" | "proximity" | "attribute" => Some(criterion), + "words" | "typo" | "proximity" | "attribute" | "exactness" => Some(criterion), s if s.starts_with("asc") || s.starts_with("desc") => Some(criterion), "wordsPosition" => { - warn!("The criteria `words` and `wordsPosition` have been merged into a single criterion `words` so `wordsPositon` will be ignored"); - Some(String::from("words")) - } - "exactness" => { - error!("The criterion `{}` is not implemented currently and thus will be ignored", criterion); + warn!("The criteria `attribute` and `wordsPosition` have been merged into a single criterion `attribute` so `wordsPositon` will be ignored"); None } s => { From 8f05d8d546d56631e4ec748a4c24e71f870d778f Mon Sep 17 00:00:00 2001 From: mpostma Date: Thu, 5 Aug 2021 15:43:48 +0200 Subject: [PATCH 4/4] fix clippy warnings --- Cargo.lock | 2 +- .../src/index_controller/dump_actor/loaders/v1.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f9ea7184c..c1adeeabc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1700,7 +1700,7 @@ dependencies = [ [[package]] name = "meilisearch-tokenizer" version = "0.2.3" -source = "git+https://github.com/meilisearch/Tokenizer.git?tag=v0.2.3#c2399c3f879144ad92e20ae057e14984dfd22781" +source = "git+https://github.com/meilisearch/tokenizer.git?tag=v0.2.3#c2399c3f879144ad92e20ae057e14984dfd22781" dependencies = [ "character_converter", "cow-utils", diff --git a/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs b/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs index 034e464b1..30923584e 100644 --- a/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs +++ b/meilisearch-http/src/index_controller/dump_actor/loaders/v1.rs @@ -144,17 +144,17 @@ impl From for index_controller::Settings { // String filterable_attributes: settings.attributes_for_faceting.map(|o| o.map(|vec| vec.into_iter().collect())), // we need to convert the old `Vec` into a `BTreeSet` - ranking_rules: settings.ranking_rules.map(|o| o.map(|vec| vec.into_iter().filter_map(|criterion| { + ranking_rules: settings.ranking_rules.map(|o| o.map(|vec| vec.into_iter().filter(|criterion| { match criterion.as_str() { - "words" | "typo" | "proximity" | "attribute" | "exactness" => Some(criterion), - s if s.starts_with("asc") || s.starts_with("desc") => Some(criterion), + "words" | "typo" | "proximity" | "attribute" | "exactness" => true, + s if s.starts_with("asc") || s.starts_with("desc") => true, "wordsPosition" => { warn!("The criteria `attribute` and `wordsPosition` have been merged into a single criterion `attribute` so `wordsPositon` will be ignored"); - None + false } s => { error!("Unknown criterion found in the dump: `{}`, it will be ignored", s); - None + false } } }).collect())),