mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-11 14:04:31 +01:00
Add a test to make sure we throw the right error message
This commit is contained in:
parent
fd3daa4423
commit
5989528833
@ -13,6 +13,7 @@ use slice_group_by::GroupBy;
|
|||||||
mod distinct;
|
mod distinct;
|
||||||
mod filters;
|
mod filters;
|
||||||
mod query_criteria;
|
mod query_criteria;
|
||||||
|
mod sort;
|
||||||
|
|
||||||
pub const TEST_QUERY: &'static str = "hello world america";
|
pub const TEST_QUERY: &'static str = "hello world america";
|
||||||
|
|
||||||
|
23
milli/tests/search/sort.rs
Normal file
23
milli/tests/search/sort.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
use big_s::S;
|
||||||
|
use milli::Criterion::{Attribute, Exactness, Proximity, Typo, Words};
|
||||||
|
use milli::{AscDesc, Error, Search, UserError};
|
||||||
|
|
||||||
|
use crate::search::{self, EXTERNAL_DOCUMENTS_IDS};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sort_ranking_rule_missing() {
|
||||||
|
let criteria = vec![Words, Typo, Proximity, Attribute, Exactness];
|
||||||
|
// sortables: `tag` and `asc_desc_rank`
|
||||||
|
let index = search::setup_search_index_with_criteria(&criteria);
|
||||||
|
let rtxn = index.read_txn().unwrap();
|
||||||
|
|
||||||
|
let mut search = Search::new(&rtxn, &index);
|
||||||
|
search.query(search::TEST_QUERY);
|
||||||
|
search.limit(EXTERNAL_DOCUMENTS_IDS.len());
|
||||||
|
search.authorize_typos(true);
|
||||||
|
search.optional_words(true);
|
||||||
|
search.sort_criteria(vec![AscDesc::Asc(S("tag"))]);
|
||||||
|
|
||||||
|
let result = search.execute();
|
||||||
|
assert!(matches!(result, Err(Error::UserError(UserError::SortRankingRuleMissing))));
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user