mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
BoxRankingRule
This commit is contained in:
parent
8d7d8cdc2f
commit
b4a52a622e
@ -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<QueryGraph> for DetailedSearchLogger {
|
||||
fn initial_universe(&mut self, universe: &RoaringBitmap) {
|
||||
self.initial_universe = Some(universe.clone());
|
||||
}
|
||||
fn ranking_rules(&mut self, rr: &[Box<dyn RankingRule<QueryGraph>>]) {
|
||||
fn ranking_rules(&mut self, rr: &[BoxRankingRule<QueryGraph>]) {
|
||||
self.ranking_rules_ids = Some(rr.iter().map(|rr| rr.id()).collect());
|
||||
}
|
||||
|
||||
|
@ -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<Q: RankingRuleQueryTrait> {
|
||||
fn initial_universe(&mut self, universe: &RoaringBitmap);
|
||||
|
||||
/// Logs the ranking rules used to perform the search query
|
||||
fn ranking_rules(&mut self, rr: &[Box<dyn RankingRule<Q>>]);
|
||||
fn ranking_rules(&mut self, rr: &[BoxRankingRule<Q>]);
|
||||
|
||||
/// Logs the start of a ranking rule's iteration.
|
||||
fn start_iteration_ranking_rule(
|
||||
@ -93,7 +94,7 @@ impl<Q: RankingRuleQueryTrait> SearchLogger<Q> for DefaultSearchLogger {
|
||||
|
||||
fn initial_universe(&mut self, _universe: &RoaringBitmap) {}
|
||||
|
||||
fn ranking_rules(&mut self, _rr: &[Box<dyn RankingRule<Q>>]) {}
|
||||
fn ranking_rules(&mut self, _rr: &[BoxRankingRule<Q>]) {}
|
||||
|
||||
fn start_iteration_ranking_rule(
|
||||
&mut self,
|
||||
|
@ -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<Vec<Box<dyn RankingRule<'ctx, PlaceholderQuery>>>> {
|
||||
) -> Result<Vec<BoxRankingRule<'ctx, PlaceholderQuery>>> {
|
||||
// let sort = false;
|
||||
// let mut asc = HashSet::new();
|
||||
// let mut desc = HashSet::new();
|
||||
let /*mut*/ ranking_rules: Vec<Box<dyn RankingRule<PlaceholderQuery>>> = vec![];
|
||||
let /*mut*/ ranking_rules: Vec<BoxRankingRule<PlaceholderQuery>> = 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<Vec<Box<dyn RankingRule<'ctx, QueryGraph>>>> {
|
||||
) -> Result<Vec<BoxRankingRule<'ctx, QueryGraph>>> {
|
||||
// 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<Box<dyn RankingRule<QueryGraph>>> = vec![];
|
||||
let mut ranking_rules: Vec<BoxRankingRule<QueryGraph>> = 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
|
||||
|
@ -15,6 +15,8 @@ pub struct PlaceholderQuery;
|
||||
impl RankingRuleQueryTrait for PlaceholderQuery {}
|
||||
impl RankingRuleQueryTrait for QueryGraph {}
|
||||
|
||||
pub type BoxRankingRule<'ctx, Query> = Box<dyn RankingRule<'ctx, Query> + '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<Q> {
|
||||
|
||||
pub fn bucket_sort<'ctx, Q: RankingRuleQueryTrait>(
|
||||
ctx: &mut SearchContext<'ctx>,
|
||||
mut ranking_rules: Vec<Box<dyn RankingRule<'ctx, Q>>>,
|
||||
mut ranking_rules: Vec<BoxRankingRule<'ctx, Q>>,
|
||||
query: &Q,
|
||||
universe: &RoaringBitmap,
|
||||
from: usize,
|
||||
|
Loading…
Reference in New Issue
Block a user