diff --git a/meilisearch-core/src/bucket_sort.rs b/meilisearch-core/src/bucket_sort.rs index a0609d30d..f173c2955 100644 --- a/meilisearch-core/src/bucket_sort.rs +++ b/meilisearch-core/src/bucket_sort.rs @@ -446,7 +446,7 @@ fn fetch_matches<'txn, 'tag>( ) -> MResult>> { let before_words_fst = Instant::now(); - let words = match main_store.words_fst(reader)? { + let words = match unsafe { main_store.static_words_fst(reader)? } { Some(words) => words, None => return Ok(Vec::new()), }; diff --git a/meilisearch-core/src/store/main.rs b/meilisearch-core/src/store/main.rs index 0efdd140e..90c662db4 100644 --- a/meilisearch-core/src/store/main.rs +++ b/meilisearch-core/src/store/main.rs @@ -67,6 +67,17 @@ impl Main { self.main.put::<_, Str, ByteSlice>(writer, WORDS_KEY, bytes) } + pub unsafe fn static_words_fst(self, reader: &heed::RoTxn) -> ZResult> { + match self.main.get::<_, Str, ByteSlice>(reader, WORDS_KEY)? { + Some(bytes) => { + let bytes: &'static [u8] = std::mem::transmute(bytes); + let set = fst::Set::from_static_slice(bytes).unwrap(); + Ok(Some(set)) + } + None => Ok(None), + } + } + pub fn words_fst(self, reader: &heed::RoTxn) -> ZResult> { match self.main.get::<_, Str, ByteSlice>(reader, WORDS_KEY)? { Some(bytes) => {