mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-26 16:21:07 +00:00
Remove excluded document in criteria iterations
- pass excluded document to criteria to remove them in higher levels of the bucket-sort - merge already returned document with excluded documents to avoid duplicas Related to #125 and #112 Fix #170
This commit is contained in:
@ -165,13 +165,13 @@ impl<'a> Search<'a> {
|
||||
) -> anyhow::Result<SearchResult> {
|
||||
let mut offset = self.offset;
|
||||
let mut initial_candidates = RoaringBitmap::new();
|
||||
let mut excluded_documents = RoaringBitmap::new();
|
||||
let mut excluded_candidates = RoaringBitmap::new();
|
||||
let mut documents_ids = Vec::with_capacity(self.limit);
|
||||
|
||||
while let Some(FinalResult { candidates, bucket_candidates, .. }) = criteria.next()? {
|
||||
while let Some(FinalResult { candidates, bucket_candidates, .. }) = criteria.next(&excluded_candidates)? {
|
||||
debug!("Number of candidates found {}", candidates.len());
|
||||
|
||||
let excluded = take(&mut excluded_documents);
|
||||
let excluded = take(&mut excluded_candidates);
|
||||
|
||||
let mut candidates = distinct.distinct(candidates, excluded);
|
||||
|
||||
@ -186,7 +186,7 @@ impl<'a> Search<'a> {
|
||||
documents_ids.push(candidate?);
|
||||
}
|
||||
if documents_ids.len() == self.limit { break }
|
||||
excluded_documents = candidates.into_excluded();
|
||||
excluded_candidates = candidates.into_excluded();
|
||||
}
|
||||
|
||||
Ok(SearchResult { matching_words, candidates: initial_candidates, documents_ids })
|
||||
|
Reference in New Issue
Block a user