Use the new Asc/Desc syntax everywhere

This commit is contained in:
Kerollmops 2021-08-17 14:13:00 +02:00
parent fcedff95e8
commit 5b88df508e
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
4 changed files with 12 additions and 12 deletions

View File

@ -52,9 +52,9 @@ fn bench_songs(c: &mut criterion::Criterion) {
milli::default_criteria().iter().map(|criteria| criteria.to_string()).collect(); milli::default_criteria().iter().map(|criteria| criteria.to_string()).collect();
let default_criterion = default_criterion.iter().map(|s| s.as_str()); let default_criterion = default_criterion.iter().map(|s| s.as_str());
let asc_default: Vec<&str> = let asc_default: Vec<&str> =
std::iter::once("asc(released-timestamp)").chain(default_criterion.clone()).collect(); std::iter::once("released-timestamp:asc").chain(default_criterion.clone()).collect();
let desc_default: Vec<&str> = let desc_default: Vec<&str> =
std::iter::once("desc(released-timestamp)").chain(default_criterion.clone()).collect(); std::iter::once("released-timestamp:desc").chain(default_criterion.clone()).collect();
let basic_with_quote: Vec<String> = BASE_CONF let basic_with_quote: Vec<String> = BASE_CONF
.queries .queries
@ -118,12 +118,12 @@ fn bench_songs(c: &mut criterion::Criterion) {
}, },
utils::Conf { utils::Conf {
group_name: "asc", group_name: "asc",
criterion: Some(&["asc(released-timestamp)"]), criterion: Some(&["released-timestamp:desc"]),
..BASE_CONF ..BASE_CONF
}, },
utils::Conf { utils::Conf {
group_name: "desc", group_name: "desc",
criterion: Some(&["desc(released-timestamp)"]), criterion: Some(&["released-timestamp:desc"]),
..BASE_CONF ..BASE_CONF
}, },

View File

@ -1030,7 +1030,7 @@ mod tests {
displayed_attributes: Setting::Set(vec!["name".to_string()]), displayed_attributes: Setting::Set(vec!["name".to_string()]),
searchable_attributes: Setting::Set(vec!["age".to_string()]), searchable_attributes: Setting::Set(vec!["age".to_string()]),
filterable_attributes: Setting::Set(hashset! { "age".to_string() }), filterable_attributes: Setting::Set(hashset! { "age".to_string() }),
criteria: Setting::Set(vec!["asc(age)".to_string()]), criteria: Setting::Set(vec!["age:asc".to_string()]),
stop_words: Setting::Set(btreeset! { "and".to_string() }), stop_words: Setting::Set(btreeset! { "and".to_string() }),
synonyms: Setting::Set(hashmap! { "alex".to_string() => vec!["alexey".to_string()] }), synonyms: Setting::Set(hashmap! { "alex".to_string() => vec!["alexey".to_string()] }),
}; };
@ -1058,7 +1058,7 @@ mod tests {
Token::Str("criteria"), Token::Str("criteria"),
Token::Some, Token::Some,
Token::Seq { len: Some(1) }, Token::Seq { len: Some(1) },
Token::Str("asc(age)"), Token::Str("age:asc"),
Token::SeqEnd, Token::SeqEnd,
Token::Str("stopWords"), Token::Str("stopWords"),
Token::Some, Token::Some,

View File

@ -15,7 +15,7 @@ pub enum Criterion {
/// Sorted by increasing distance between matched query terms. /// Sorted by increasing distance between matched query terms.
Proximity, Proximity,
/// Documents with quey words contained in more important /// Documents with quey words contained in more important
/// attributes are considred better. /// attributes are considered better.
Attribute, Attribute,
/// Sorted by the similarity of the matched words with the query words. /// Sorted by the similarity of the matched words with the query words.
Exactness, Exactness,
@ -74,8 +74,8 @@ impl fmt::Display for Criterion {
Proximity => f.write_str("proximity"), Proximity => f.write_str("proximity"),
Attribute => f.write_str("attribute"), Attribute => f.write_str("attribute"),
Exactness => f.write_str("exactness"), Exactness => f.write_str("exactness"),
Asc(attr) => write!(f, "asc({})", attr), Asc(attr) => write!(f, "{}:asc", attr),
Desc(attr) => write!(f, "desc({})", attr), Desc(attr) => write!(f, "{}:desc", attr),
} }
} }
} }

View File

@ -719,7 +719,7 @@ mod tests {
let mut builder = Settings::new(&mut wtxn, &index, 0); let mut builder = Settings::new(&mut wtxn, &index, 0);
// Don't display the generated `id` field. // Don't display the generated `id` field.
builder.set_displayed_fields(vec![S("name")]); builder.set_displayed_fields(vec![S("name")]);
builder.set_criteria(vec![S("asc(age)")]); builder.set_criteria(vec![S("age:asc")]);
builder.execute(|_, _| ()).unwrap(); builder.execute(|_, _| ()).unwrap();
// Then index some documents. // Then index some documents.
@ -953,7 +953,7 @@ mod tests {
let mut builder = Settings::new(&mut wtxn, &index, 0); let mut builder = Settings::new(&mut wtxn, &index, 0);
builder.set_displayed_fields(vec!["hello".to_string()]); builder.set_displayed_fields(vec!["hello".to_string()]);
builder.set_filterable_fields(hashset! { S("age"), S("toto") }); builder.set_filterable_fields(hashset! { S("age"), S("toto") });
builder.set_criteria(vec!["asc(toto)".to_string()]); builder.set_criteria(vec!["toto:asc".to_string()]);
builder.execute(|_, _| ()).unwrap(); builder.execute(|_, _| ()).unwrap();
wtxn.commit().unwrap(); wtxn.commit().unwrap();
@ -990,7 +990,7 @@ mod tests {
let mut builder = Settings::new(&mut wtxn, &index, 0); let mut builder = Settings::new(&mut wtxn, &index, 0);
builder.set_displayed_fields(vec!["hello".to_string()]); builder.set_displayed_fields(vec!["hello".to_string()]);
// It is only Asc(toto), there is a facet database but it is denied to filter with toto. // It is only Asc(toto), there is a facet database but it is denied to filter with toto.
builder.set_criteria(vec!["asc(toto)".to_string()]); builder.set_criteria(vec!["toto:asc".to_string()]);
builder.execute(|_, _| ()).unwrap(); builder.execute(|_, _| ()).unwrap();
wtxn.commit().unwrap(); wtxn.commit().unwrap();