diff --git a/meilisearch-core/src/database.rs b/meilisearch-core/src/database.rs index 3326eb9cd..650cadd5b 100644 --- a/meilisearch-core/src/database.rs +++ b/meilisearch-core/src/database.rs @@ -1065,7 +1065,7 @@ mod tests { "attribute", "wordsPosition", "exactness", - "dsc(release_date)" + "desc(release_date)" ], "searchableAttributes": ["name", "release_date"], "displayedAttributes": ["name", "release_date"] diff --git a/meilisearch-core/src/settings.rs b/meilisearch-core/src/settings.rs index 11344a833..d506258cd 100644 --- a/meilisearch-core/src/settings.rs +++ b/meilisearch-core/src/settings.rs @@ -10,7 +10,7 @@ use self::RankingRule::*; pub const DEFAULT_RANKING_RULES: [RankingRule; 6] = [Typo, Words, Proximity, Attribute, WordsPosition, Exactness]; static RANKING_RULE_REGEX: Lazy = Lazy::new(|| { - let regex = regex::Regex::new(r"(asc|dsc)\(([a-zA-Z0-9-_]*)\)").unwrap(); + let regex = regex::Regex::new(r"(asc|desc)\(([a-zA-Z0-9-_]*)\)").unwrap(); regex }); @@ -99,7 +99,7 @@ pub enum RankingRule { WordsPosition, Exactness, Asc(String), - Dsc(String), + Desc(String), } impl std::fmt::Display for RankingRule { @@ -112,7 +112,7 @@ impl std::fmt::Display for RankingRule { RankingRule::WordsPosition => f.write_str("wordsPosition"), RankingRule::Exactness => f.write_str("exactness"), RankingRule::Asc(field) => write!(f, "asc({})", field), - RankingRule::Dsc(field) => write!(f, "dsc({})", field), + RankingRule::Desc(field) => write!(f, "desc({})", field), } } } @@ -132,7 +132,7 @@ impl FromStr for RankingRule { let captures = RANKING_RULE_REGEX.captures(s).ok_or(RankingRuleConversionError)?; match (captures.get(1).map(|m| m.as_str()), captures.get(2)) { (Some("asc"), Some(field)) => RankingRule::Asc(field.as_str().to_string()), - (Some("dsc"), Some(field)) => RankingRule::Dsc(field.as_str().to_string()), + (Some("desc"), Some(field)) => RankingRule::Desc(field.as_str().to_string()), _ => return Err(RankingRuleConversionError) } } @@ -144,7 +144,7 @@ impl FromStr for RankingRule { impl RankingRule { pub fn field(&self) -> Option<&str> { match self { - RankingRule::Asc(field) | RankingRule::Dsc(field) => Some(field), + RankingRule::Asc(field) | RankingRule::Desc(field) => Some(field), _ => None, } } diff --git a/meilisearch-http/src/helpers/meilisearch.rs b/meilisearch-http/src/helpers/meilisearch.rs index 3d2b2f399..377bb1ae9 100644 --- a/meilisearch-http/src/helpers/meilisearch.rs +++ b/meilisearch-http/src/helpers/meilisearch.rs @@ -313,7 +313,7 @@ impl<'a> SearchBuilder<'a> { Err(err) => error!("Error during criteria builder; {:?}", err), } } - RankingRule::Dsc(field) => { + RankingRule::Desc(field) => { match SortByAttr::higher_is_better(&ranked_map, &schema, &field) { Ok(rule) => builder.push(rule), Err(err) => error!("Error during criteria builder; {:?}", err), diff --git a/meilisearch-http/tests/common.rs b/meilisearch-http/tests/common.rs index 605caa833..fd2f53742 100644 --- a/meilisearch-http/tests/common.rs +++ b/meilisearch-http/tests/common.rs @@ -62,9 +62,9 @@ pub fn enrich_server_with_movies_settings( "proximity", "attribute", "wordsPosition", - "dsc(popularity)", + "desc(popularity)", "exactness", - "dsc(vote_average)", + "desc(vote_average)", ], "distinctAttribute": null, "searchableAttributes": [ diff --git a/meilisearch-http/tests/search.rs b/meilisearch-http/tests/search.rs index b03ff4a0d..1bb37be8a 100644 --- a/meilisearch-http/tests/search.rs +++ b/meilisearch-http/tests/search.rs @@ -631,9 +631,9 @@ fn search_with_settings_basic() { "proximity", "attribute", "wordsPosition", - "dsc(popularity)", + "desc(popularity)", "exactness", - "dsc(vote_average)" + "desc(vote_average)" ], "distinctAttribute": null, "identifier": "id", @@ -737,9 +737,9 @@ fn search_with_settings_stop_words() { "proximity", "attribute", "wordsPosition", - "dsc(popularity)", + "desc(popularity)", "exactness", - "dsc(vote_average)" + "desc(vote_average)" ], "distinctAttribute": null, "identifier": "id", @@ -844,9 +844,9 @@ fn search_with_settings_synonyms() { "proximity", "attribute", "wordsPosition", - "dsc(popularity)", + "desc(popularity)", "exactness", - "dsc(vote_average)" + "desc(vote_average)" ], "distinctAttribute": null, "identifier": "id", @@ -958,7 +958,7 @@ fn search_with_settings_ranking_rules() { "wordsPosition", "asc(vote_average)", "exactness", - "dsc(popularity)" + "desc(popularity)" ], "distinctAttribute": null, "identifier": "id", @@ -1063,9 +1063,9 @@ fn search_with_settings_searchable_attributes() { "proximity", "attribute", "wordsPosition", - "dsc(popularity)", + "desc(popularity)", "exactness", - "dsc(vote_average)" + "desc(vote_average)" ], "distinctAttribute": null, "identifier": "id", @@ -1169,9 +1169,9 @@ fn search_with_settings_displayed_attributes() { "proximity", "attribute", "wordsPosition", - "dsc(popularity)", + "desc(popularity)", "exactness", - "dsc(vote_average)" + "desc(vote_average)" ], "distinctAttribute": null, "identifier": "id", @@ -1240,9 +1240,9 @@ fn search_with_settings_searchable_attributes_2() { "proximity", "attribute", "wordsPosition", - "dsc(popularity)", + "desc(popularity)", "exactness", - "dsc(vote_average)" + "desc(vote_average)" ], "distinctAttribute": null, "identifier": "id", diff --git a/meilisearch-http/tests/settings.rs b/meilisearch-http/tests/settings.rs index 09a8c96bd..eedd8cb53 100644 --- a/meilisearch-http/tests/settings.rs +++ b/meilisearch-http/tests/settings.rs @@ -47,8 +47,8 @@ fn write_all_and_delete() { "attribute", "wordsPosition", "exactness", - "dsc(release_date)", - "dsc(rank)", + "desc(release_date)", + "desc(rank)", ], "distinctAttribute": "movie_id", "searchableAttributes": [ @@ -198,8 +198,8 @@ fn write_all_and_update() { "attribute", "wordsPosition", "exactness", - "dsc(release_date)", - "dsc(rank)", + "desc(release_date)", + "desc(rank)", ], "distinctAttribute": "movie_id", "searchableAttributes": [ @@ -264,7 +264,7 @@ fn write_all_and_update() { "attribute", "wordsPosition", "exactness", - "dsc(release_date)", + "desc(release_date)", ], "searchableAttributes": [ "title", @@ -317,7 +317,7 @@ fn write_all_and_update() { "attribute", "wordsPosition", "exactness", - "dsc(release_date)", + "desc(release_date)", ], "distinctAttribute": null, "searchableAttributes": [ diff --git a/meilisearch-http/tests/settings_ranking_rules.rs b/meilisearch-http/tests/settings_ranking_rules.rs index 786f72dd5..66ee08393 100644 --- a/meilisearch-http/tests/settings_ranking_rules.rs +++ b/meilisearch-http/tests/settings_ranking_rules.rs @@ -45,8 +45,8 @@ fn write_all_and_delete() { "attribute", "wordsPosition", "exactness", - "dsc(release_date)", - "dsc(rank)", + "desc(release_date)", + "desc(rank)", ]); let body = json.to_string().into_bytes(); @@ -143,8 +143,8 @@ fn write_all_and_update() { "attribute", "wordsPosition", "exactness", - "dsc(release_date)", - "dsc(rank)", + "desc(release_date)", + "desc(rank)", ]); let body = json.to_string().into_bytes(); @@ -180,7 +180,7 @@ fn write_all_and_update() { "attribute", "wordsPosition", "exactness", - "dsc(release_date)", + "desc(release_date)", ]); let body_update = json_update.to_string().into_bytes(); @@ -212,7 +212,7 @@ fn write_all_and_update() { "attribute", "wordsPosition", "exactness", - "dsc(release_date)", + "desc(release_date)", ]); assert_json_eq!(res_expected, res_value, ordered: false);