mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 10:37:41 +08:00
update the default ordering of the criterion
This commit is contained in:
parent
ee3f93c029
commit
0a4bde1f2f
@ -14,18 +14,16 @@ static ASC_DESC_REGEX: Lazy<Regex> = 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<String, FacetType>, txt: &str) -> anyhow::Result<Criterion> {
|
||||
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<Criterion> {
|
||||
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),
|
||||
|
Loading…
Reference in New Issue
Block a user