diff --git a/src/rank/query_builder.rs b/src/rank/query_builder.rs index 2d9795a55..5d6483d2e 100644 --- a/src/rank/query_builder.rs +++ b/src/rank/query_builder.rs @@ -17,8 +17,12 @@ use crate::rank::Document; fn split_whitespace_automatons(query: &str) -> Vec { let mut automatons = Vec::new(); - for query in query.split_whitespace().map(str::to_lowercase) { - let lev = automaton::build_prefix_dfa(&query); + let mut words = query.split_whitespace().map(str::to_lowercase).peekable(); + while let Some(word) = words.next() { + let lev = match words.peek() { + Some(_) => automaton::build_dfa(&word), + None => automaton::build_prefix_dfa(&word), + }; automatons.push(lev); } automatons