mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
Introduce the maximum_typo helper function
This commit is contained in:
parent
1dc857a4b2
commit
6008f528d0
@ -514,6 +514,16 @@ fn create_primitive_query(query: TokenStream) -> PrimitiveQuery {
|
||||
primitive_query
|
||||
}
|
||||
|
||||
/// Returns the maximum number of typos that this Operation allows.
|
||||
pub fn maximum_typo(operation: &Operation) -> usize {
|
||||
use Operation::{Or, And, Query, Consecutive};
|
||||
match operation {
|
||||
Or(_, ops) => ops.iter().map(maximum_typo).max().unwrap_or(0),
|
||||
And(ops) | Consecutive(ops) => ops.iter().map(maximum_typo).sum::<usize>(),
|
||||
Query(q) => q.kind.typo() as usize,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use fst::Set;
|
||||
|
Loading…
Reference in New Issue
Block a user