mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-18 08:48:32 +08:00
change wording of custom ranking rules dsc
-> desc
; #490
This commit is contained in:
parent
4d27318b72
commit
6016f2e941
@ -1065,7 +1065,7 @@ mod tests {
|
||||
"attribute",
|
||||
"wordsPosition",
|
||||
"exactness",
|
||||
"dsc(release_date)"
|
||||
"desc(release_date)"
|
||||
],
|
||||
"searchableAttributes": ["name", "release_date"],
|
||||
"displayedAttributes": ["name", "release_date"]
|
||||
|
@ -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<regex::Regex> = 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,
|
||||
}
|
||||
}
|
||||
|
@ -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),
|
||||
|
@ -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": [
|
||||
|
@ -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",
|
||||
|
@ -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": [
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user