diff --git a/milli/src/search/new/logger/detailed.rs b/milli/src/search/new/logger/detailed.rs index d6037aab2..57be61612 100644 --- a/milli/src/search/new/logger/detailed.rs +++ b/milli/src/search/new/logger/detailed.rs @@ -13,6 +13,7 @@ use crate::search::new::ranking_rule_graph::{ DeadEndsCache, Edge, ProximityCondition, ProximityGraph, RankingRuleGraph, RankingRuleGraphTrait, TypoCondition, TypoGraph, }; +use crate::search::new::ranking_rules::BoxRankingRule; use crate::search::new::{QueryGraph, QueryNode, RankingRule, SearchContext, SearchLogger}; pub enum SearchEvents { @@ -98,7 +99,7 @@ impl SearchLogger for DetailedSearchLogger { fn initial_universe(&mut self, universe: &RoaringBitmap) { self.initial_universe = Some(universe.clone()); } - fn ranking_rules(&mut self, rr: &[Box>]) { + fn ranking_rules(&mut self, rr: &[BoxRankingRule]) { self.ranking_rules_ids = Some(rr.iter().map(|rr| rr.id()).collect()); } diff --git a/milli/src/search/new/logger/mod.rs b/milli/src/search/new/logger/mod.rs index 9ebb4344a..470983017 100644 --- a/milli/src/search/new/logger/mod.rs +++ b/milli/src/search/new/logger/mod.rs @@ -8,6 +8,7 @@ use super::query_graph::QueryNode; use super::ranking_rule_graph::{ DeadEndsCache, ProximityCondition, ProximityGraph, RankingRuleGraph, TypoCondition, TypoGraph, }; +use super::ranking_rules::BoxRankingRule; use super::{RankingRule, RankingRuleQueryTrait}; /// Trait for structure logging the execution of a search query. @@ -22,7 +23,7 @@ pub trait SearchLogger { fn initial_universe(&mut self, universe: &RoaringBitmap); /// Logs the ranking rules used to perform the search query - fn ranking_rules(&mut self, rr: &[Box>]); + fn ranking_rules(&mut self, rr: &[BoxRankingRule]); /// Logs the start of a ranking rule's iteration. fn start_iteration_ranking_rule( @@ -93,7 +94,7 @@ impl SearchLogger for DefaultSearchLogger { fn initial_universe(&mut self, _universe: &RoaringBitmap) {} - fn ranking_rules(&mut self, _rr: &[Box>]) {} + fn ranking_rules(&mut self, _rr: &[BoxRankingRule]) {} fn start_iteration_ranking_rule( &mut self, diff --git a/milli/src/search/new/mod.rs b/milli/src/search/new/mod.rs index 5839787ef..66feeab99 100644 --- a/milli/src/search/new/mod.rs +++ b/milli/src/search/new/mod.rs @@ -32,7 +32,7 @@ use resolve_query_graph::{resolve_query_graph, QueryTermDocIdsCache}; use roaring::RoaringBitmap; use words::Words; -use self::ranking_rules::RankingRule; +use self::ranking_rules::{BoxRankingRule, RankingRule}; use crate::{Filter, Index, MatchingWords, Result, SearchResult, TermsMatchingStrategy}; /// A structure used throughout the execution of a search query. @@ -106,11 +106,11 @@ fn resolve_maximally_reduced_query_graph( /// Return the list of initialised ranking rules to be used for a placeholder search. fn get_ranking_rules_for_placeholder_search<'ctx>( ctx: &SearchContext<'ctx>, -) -> Result>>> { +) -> Result>> { // let sort = false; // let mut asc = HashSet::new(); // let mut desc = HashSet::new(); - let /*mut*/ ranking_rules: Vec>> = vec![]; + let /*mut*/ ranking_rules: Vec> = vec![]; let settings_ranking_rules = ctx.index.criteria(ctx.txn)?; for rr in settings_ranking_rules { // Add Words before any of: typo, proximity, attribute, exactness @@ -132,7 +132,7 @@ fn get_ranking_rules_for_placeholder_search<'ctx>( fn get_ranking_rules_for_query_graph_search<'ctx>( ctx: &SearchContext<'ctx>, terms_matching_strategy: TermsMatchingStrategy, -) -> Result>>> { +) -> Result>> { // query graph search let mut words = false; let mut typo = false; @@ -143,7 +143,7 @@ fn get_ranking_rules_for_query_graph_search<'ctx>( let mut asc = HashSet::new(); let mut desc = HashSet::new(); - let mut ranking_rules: Vec>> = vec![]; + let mut ranking_rules: Vec> = vec![]; let settings_ranking_rules = ctx.index.criteria(ctx.txn)?; for rr in settings_ranking_rules { // Add Words before any of: typo, proximity, attribute, exactness diff --git a/milli/src/search/new/ranking_rules.rs b/milli/src/search/new/ranking_rules.rs index 32434248c..1f5f4b366 100644 --- a/milli/src/search/new/ranking_rules.rs +++ b/milli/src/search/new/ranking_rules.rs @@ -15,6 +15,8 @@ pub struct PlaceholderQuery; impl RankingRuleQueryTrait for PlaceholderQuery {} impl RankingRuleQueryTrait for QueryGraph {} +pub type BoxRankingRule<'ctx, Query> = Box + 'ctx>; + /// A trait that must be implemented by all ranking rules. /// /// It is generic over `'ctx`, the lifetime of the search context @@ -70,7 +72,7 @@ pub struct RankingRuleOutput { pub fn bucket_sort<'ctx, Q: RankingRuleQueryTrait>( ctx: &mut SearchContext<'ctx>, - mut ranking_rules: Vec>>, + mut ranking_rules: Vec>, query: &Q, universe: &RoaringBitmap, from: usize,