From 9ec9c204d3a65afbcc8562ced7faa24b803c759f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lecrenier?= Date: Thu, 9 Mar 2023 15:53:59 +0100 Subject: [PATCH] Small code cleanup --- milli/src/search/new/query_term.rs | 16 +++++++--------- milli/src/search/new/resolve_query_graph.rs | 1 + 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/milli/src/search/new/query_term.rs b/milli/src/search/new/query_term.rs index 1b709d0e9..5fffe6653 100644 --- a/milli/src/search/new/query_term.rs +++ b/milli/src/search/new/query_term.rs @@ -80,7 +80,7 @@ pub fn word_derivations( word: &str, max_typo: u8, is_prefix: bool, -) -> Result { +) -> Result> { let fst = ctx.index.words_fst(ctx.txn)?; let word_interned = ctx.word_interner.insert(word.to_owned()); @@ -185,7 +185,7 @@ pub fn word_derivations( }) .collect(); - Ok(WordDerivations { + let interned = ctx.derivations_interner.insert(WordDerivations { original: ctx.word_interner.insert(word.to_owned()), synonyms, split_words, @@ -193,7 +193,9 @@ pub fn word_derivations( one_typo: one_typo.into_boxed_slice(), two_typos: two_typos.into_boxed_slice(), use_prefix_db, - }) + }); + + Ok(interned) } /// Split the original word into the two words that appear the @@ -342,9 +344,7 @@ pub fn located_query_terms_from_string<'search>( let word = token.lemma(); let derivations = word_derivations(ctx, word, nbr_typos(word), false)?; let located_term = LocatedQueryTerm { - value: QueryTerm::Word { - derivations: ctx.derivations_interner.insert(derivations), - }, + value: QueryTerm::Word { derivations }, positions: position..=position, }; located_terms.push(located_term); @@ -355,9 +355,7 @@ pub fn located_query_terms_from_string<'search>( let word = token.lemma(); let derivations = word_derivations(ctx, word, nbr_typos(word), true)?; let located_term = LocatedQueryTerm { - value: QueryTerm::Word { - derivations: ctx.derivations_interner.insert(derivations), - }, + value: QueryTerm::Word { derivations }, positions: position..=position, }; located_terms.push(located_term); diff --git a/milli/src/search/new/resolve_query_graph.rs b/milli/src/search/new/resolve_query_graph.rs index 4606b9226..b70b01c34 100644 --- a/milli/src/search/new/resolve_query_graph.rs +++ b/milli/src/search/new/resolve_query_graph.rs @@ -150,6 +150,7 @@ pub fn resolve_query_graph<'search>( phrase_interner, derivations_interner, query_term_docids, + .. } = ctx; // TODO: there is a faster way to compute this big // roaring bitmap expression