From 1163f390b387d6dd59673b1be9aff10373ca5662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Fri, 20 Dec 2019 16:36:37 +0100 Subject: [PATCH] Restrict FST search to the first letter of the word --- meilisearch-core/src/bucket_sort.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/meilisearch-core/src/bucket_sort.rs b/meilisearch-core/src/bucket_sort.rs index 7148f6261..a0609d30d 100644 --- a/meilisearch-core/src/bucket_sort.rs +++ b/meilisearch-core/src/bucket_sort.rs @@ -467,7 +467,13 @@ fn fetch_matches<'txn, 'tag>( dfa_time += before_dfa.elapsed(); let mut number_of_words = 0; - let mut stream = words.search(&dfa).into_stream(); + + let byte = query.as_bytes()[0]; + let mut stream = if byte == u8::max_value() { + words.search(&dfa).ge(&[byte]).into_stream() + } else { + words.search(&dfa).ge(&[byte]).lt(&[byte + 1]).into_stream() + }; // while let Some(input) = stream.next() { loop {