mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 16:51:01 +00:00
Implement the previous way for the exhaustive distinct candidates
This commit is contained in:
committed by
Loïc Lecrenier
parent
55fbfb6124
commit
0d2e7bcc13
@ -37,6 +37,7 @@ use self::interner::Interner;
|
||||
use self::ranking_rules::{BoxRankingRule, RankingRule};
|
||||
use self::resolve_query_graph::compute_query_graph_docids;
|
||||
use self::sort::Sort;
|
||||
use crate::search::new::distinct::{apply_distinct_rule, DistinctOutput};
|
||||
use crate::{
|
||||
AscDesc, Filter, Index, MatchingWords, Member, Result, SearchResult, TermsMatchingStrategy,
|
||||
UserError,
|
||||
@ -272,6 +273,7 @@ pub fn execute_search(
|
||||
ctx: &mut SearchContext,
|
||||
query: &Option<String>,
|
||||
terms_matching_strategy: TermsMatchingStrategy,
|
||||
exhaustive_number_hits: bool,
|
||||
filters: &Option<Filter>,
|
||||
sort_criteria: &Option<Vec<AscDesc>>,
|
||||
from: usize,
|
||||
@ -333,11 +335,21 @@ pub fn execute_search(
|
||||
)?
|
||||
};
|
||||
|
||||
// The candidates is the universe unless the exhaustive number of hits
|
||||
// is requested and a distinct attribute is set.
|
||||
let mut candidates = universe;
|
||||
if exhaustive_number_hits {
|
||||
if let Some(f) = ctx.index.distinct_field(ctx.txn)? {
|
||||
if let Some(distinct_fid) = ctx.index.fields_ids_map(ctx.txn)?.id(f) {
|
||||
candidates = apply_distinct_rule(ctx, distinct_fid, &candidates)?.remaining;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(SearchResult {
|
||||
// TODO: correct matching words
|
||||
matching_words: MatchingWords::default(),
|
||||
// TODO: candidates with distinct
|
||||
candidates: universe,
|
||||
candidates,
|
||||
documents_ids,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user