mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-28 01:01:00 +00:00
add tests for min_word_len_for_typo
This commit is contained in:
@ -264,6 +264,7 @@ fn split_best_frequency(ctx: &impl Context, word: &str) -> heed::Result<Option<O
|
||||
Ok(best.map(|(_, left, right)| Operation::Phrase(vec![left.to_string(), right.to_string()])))
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct TypoConfig {
|
||||
pub max_typos: u8,
|
||||
pub word_len_1_typo: u8,
|
||||
@ -1219,4 +1220,24 @@ mod test {
|
||||
|
||||
assert_eq!(expected, query_tree);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_min_word_len_typo() {
|
||||
let config = TypoConfig { max_typos: 2, word_len_1_typo: 5, word_len_2_typo: 7 };
|
||||
|
||||
assert_eq!(
|
||||
typos("hello".to_string(), true, config.clone()),
|
||||
QueryKind::Tolerant { typo: 1, word: "hello".to_string() }
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
typos("hell".to_string(), true, config.clone()),
|
||||
QueryKind::exact("hell".to_string())
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
typos("verylongword".to_string(), true, config.clone()),
|
||||
QueryKind::Tolerant { typo: 2, word: "verylongword".to_string() }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user