2020-11-27 12:14:56 +01:00
|
|
|
use crate::FieldId;
|
|
|
|
|
|
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Copy, Clone, PartialEq, Eq)]
|
2020-08-12 10:43:02 +02:00
|
|
|
pub enum Criterion {
|
|
|
|
/// 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.
|
2020-11-27 12:14:56 +01:00
|
|
|
Asc(FieldId),
|
2020-08-12 10:43:02 +02:00
|
|
|
/// Sorted by the decreasing value of the field specified.
|
2020-11-27 12:14:56 +01:00
|
|
|
Desc(FieldId),
|
2020-08-12 10:43:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn default_criteria() -> Vec<Criterion> {
|
|
|
|
vec![
|
|
|
|
Criterion::Typo,
|
|
|
|
Criterion::Words,
|
|
|
|
Criterion::Proximity,
|
|
|
|
Criterion::Attribute,
|
|
|
|
Criterion::WordsPosition,
|
|
|
|
Criterion::Exactness,
|
|
|
|
]
|
|
|
|
}
|