mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-31 07:23:15 +08:00
refactor typos for readability
This commit is contained in:
parent
66020cd923
commit
950a740bd4
@ -276,9 +276,9 @@ pub struct TypoConfig {
|
|||||||
fn typos(word: String, authorize_typos: bool, config: TypoConfig) -> QueryKind {
|
fn typos(word: String, authorize_typos: bool, config: TypoConfig) -> QueryKind {
|
||||||
if authorize_typos {
|
if authorize_typos {
|
||||||
let count = word.chars().count().min(u8::MAX as usize) as u8;
|
let count = word.chars().count().min(u8::MAX as usize) as u8;
|
||||||
if (0..config.word_len_one_typo).contains(&count) {
|
if count < config.word_len_one_typo {
|
||||||
QueryKind::exact(word)
|
QueryKind::exact(word)
|
||||||
} else if (config.word_len_one_typo..config.word_len_two_typo).contains(&count) {
|
} else if count < config.word_len_two_typo {
|
||||||
QueryKind::tolerant(1.min(config.max_typos), word)
|
QueryKind::tolerant(1.min(config.max_typos), word)
|
||||||
} else {
|
} else {
|
||||||
QueryKind::tolerant(2.min(config.max_typos), word)
|
QueryKind::tolerant(2.min(config.max_typos), word)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user