From 0a4bde1f2fd87bf8e79f8d75176661527a0eb412 Mon Sep 17 00:00:00 2001 From: tamo Date: Thu, 1 Apr 2021 19:13:18 +0200 Subject: [PATCH] update the default ordering of the criterion --- milli/src/criterion.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/milli/src/criterion.rs b/milli/src/criterion.rs index 40f9a3e0b..8bae99a20 100644 --- a/milli/src/criterion.rs +++ b/milli/src/criterion.rs @@ -14,18 +14,16 @@ static ASC_DESC_REGEX: Lazy = Lazy::new(|| { #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] pub enum Criterion { + /// Sorted by decreasing number of matched query terms. + /// Query words at the front of an attribute is considered better than if it was at the back. + Words, /// Sorted by increasing number of typos. Typo, - /// Sorted by decreasing number of matched query terms. - Words, /// Sorted by increasing distance between matched query terms. Proximity, /// Documents with quey words contained in more important /// attributes are considred better. Attribute, - /// Documents with query words at the front of an attribute is - /// considered better than if it was at the back. - WordsPosition, /// Sorted by the similarity of the matched words with the query words. Exactness, /// Sorted by the increasing value of the field specified. @@ -37,11 +35,10 @@ pub enum Criterion { impl Criterion { pub fn from_str(faceted_attributes: &HashMap, txt: &str) -> anyhow::Result { match txt { - "typo" => Ok(Criterion::Typo), "words" => Ok(Criterion::Words), + "typo" => Ok(Criterion::Typo), "proximity" => Ok(Criterion::Proximity), "attribute" => Ok(Criterion::Attribute), - "wordsposition" => Ok(Criterion::WordsPosition), "exactness" => Ok(Criterion::Exactness), text => { let caps = ASC_DESC_REGEX.captures(text).with_context(|| format!("unknown criterion name: {}", text))?; @@ -60,11 +57,10 @@ impl Criterion { pub fn default_criteria() -> Vec { vec![ - Criterion::Typo, Criterion::Words, + Criterion::Typo, Criterion::Proximity, Criterion::Attribute, - Criterion::WordsPosition, Criterion::Exactness, ] } @@ -74,11 +70,10 @@ impl fmt::Display for Criterion { use Criterion::*; match self { - Typo => f.write_str("typo"), Words => f.write_str("words"), + Typo => f.write_str("typo"), Proximity => f.write_str("proximity"), Attribute => f.write_str("attribute"), - WordsPosition => f.write_str("wordsPosition"), Exactness => f.write_str("exactness"), Asc(attr) => write!(f, "asc({})", attr), Desc(attr) => write!(f, "desc({})", attr),