From 2d88089129a89f56e6906710359323a560a0d831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lecrenier?= Date: Tue, 21 Feb 2023 09:40:41 +0100 Subject: [PATCH] Remove unused term matching strategies --- milli/src/search/mod.rs | 9 +-------- milli/src/search/query_tree.rs | 37 ---------------------------------- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/milli/src/search/mod.rs b/milli/src/search/mod.rs index bd140284d..5e741c7f3 100644 --- a/milli/src/search/mod.rs +++ b/milli/src/search/mod.rs @@ -36,6 +36,7 @@ mod distinct; pub mod facet; mod fst_utils; mod matches; +pub mod new; mod query_tree; pub struct Search<'a> { @@ -344,14 +345,6 @@ pub enum CriterionImplementationStrategy { pub enum TermsMatchingStrategy { // remove last word first Last, - // remove first word first - First, - // remove more frequent word first - Frequency, - // remove smallest word first - Size, - // only one of the word is mandatory - Any, // all words are mandatory All, } diff --git a/milli/src/search/query_tree.rs b/milli/src/search/query_tree.rs index 541dd8f7a..24e33bdd8 100755 --- a/milli/src/search/query_tree.rs +++ b/milli/src/search/query_tree.rs @@ -487,49 +487,12 @@ fn create_query_tree( for _ in 0..=remove_count { let pos = match terms_matching_strategy { TermsMatchingStrategy::All => return ngrams(ctx, authorize_typos, &query, false), - TermsMatchingStrategy::Any => { - let operation = Operation::Or( - true, - vec![ - // branch allowing matching documents to contains any query word. - ngrams(ctx, authorize_typos, &query, true)?, - // branch forcing matching documents to contains all the query words, - // keeping this documents of the top of the resulted list. - ngrams(ctx, authorize_typos, &query, false)?, - ], - ); - - return Ok(operation); - } TermsMatchingStrategy::Last => query .iter() .enumerate() .filter(|(_, part)| !part.is_phrase()) .last() .map(|(pos, _)| pos), - TermsMatchingStrategy::First => { - query.iter().enumerate().find(|(_, part)| !part.is_phrase()).map(|(pos, _)| pos) - } - TermsMatchingStrategy::Size => query - .iter() - .enumerate() - .filter(|(_, part)| !part.is_phrase()) - .min_by_key(|(_, part)| match part { - PrimitiveQueryPart::Word(s, _) => s.len(), - _ => unreachable!(), - }) - .map(|(pos, _)| pos), - TermsMatchingStrategy::Frequency => query - .iter() - .enumerate() - .filter(|(_, part)| !part.is_phrase()) - .max_by_key(|(_, part)| match part { - PrimitiveQueryPart::Word(s, _) => { - ctx.word_documents_count(s).unwrap_or_default().unwrap_or(u64::max_value()) - } - _ => unreachable!(), - }) - .map(|(pos, _)| pos), }; // compute and push the current branch on the front