mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-27 13:47:29 +01:00
Correctly compute the bucket candidates for the Typo criterion
This commit is contained in:
parent
5344abc008
commit
229130ed25
@ -16,6 +16,7 @@ pub struct Typo<'t> {
|
|||||||
query_tree: Option<Operation>,
|
query_tree: Option<Operation>,
|
||||||
number_typos: u8,
|
number_typos: u8,
|
||||||
candidates: Candidates,
|
candidates: Candidates,
|
||||||
|
bucket_candidates: Option<RoaringBitmap>,
|
||||||
parent: Option<Box<dyn Criterion>>,
|
parent: Option<Box<dyn Criterion>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +32,7 @@ impl<'t> Typo<'t> {
|
|||||||
query_tree,
|
query_tree,
|
||||||
number_typos: 0,
|
number_typos: 0,
|
||||||
candidates: candidates.map_or_else(Candidates::default, Candidates::Allowed),
|
candidates: candidates.map_or_else(Candidates::default, Candidates::Allowed),
|
||||||
|
bucket_candidates: None,
|
||||||
parent: None,
|
parent: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -45,6 +47,7 @@ impl<'t> Typo<'t> {
|
|||||||
query_tree: None,
|
query_tree: None,
|
||||||
number_typos: 0,
|
number_typos: 0,
|
||||||
candidates: Candidates::default(),
|
candidates: Candidates::default(),
|
||||||
|
bucket_candidates: None,
|
||||||
parent: Some(parent),
|
parent: Some(parent),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -68,10 +71,15 @@ impl<'t> Criterion for Typo<'t> {
|
|||||||
candidates.difference_with(&new_candidates);
|
candidates.difference_with(&new_candidates);
|
||||||
self.number_typos += 1;
|
self.number_typos += 1;
|
||||||
|
|
||||||
|
let bucket_candidates = match self.parent {
|
||||||
|
Some(_) => self.bucket_candidates.take(),
|
||||||
|
None => Some(new_candidates.clone()),
|
||||||
|
};
|
||||||
|
|
||||||
return Ok(Some(CriterionResult {
|
return Ok(Some(CriterionResult {
|
||||||
query_tree: Some(new_query_tree),
|
query_tree: Some(new_query_tree),
|
||||||
candidates: new_candidates,
|
candidates: new_candidates,
|
||||||
bucket_candidates: None,
|
bucket_candidates,
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
(Some(query_tree), Forbidden(candidates)) => {
|
(Some(query_tree), Forbidden(candidates)) => {
|
||||||
@ -83,26 +91,33 @@ impl<'t> Criterion for Typo<'t> {
|
|||||||
candidates.union_with(&new_candidates);
|
candidates.union_with(&new_candidates);
|
||||||
self.number_typos += 1;
|
self.number_typos += 1;
|
||||||
|
|
||||||
|
let bucket_candidates = match self.parent {
|
||||||
|
Some(_) => self.bucket_candidates.take(),
|
||||||
|
None => Some(new_candidates.clone()),
|
||||||
|
};
|
||||||
|
|
||||||
return Ok(Some(CriterionResult {
|
return Ok(Some(CriterionResult {
|
||||||
query_tree: Some(new_query_tree),
|
query_tree: Some(new_query_tree),
|
||||||
candidates: new_candidates,
|
candidates: new_candidates,
|
||||||
bucket_candidates: None,
|
bucket_candidates,
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
(None, Allowed(_)) => {
|
(None, Allowed(_)) => {
|
||||||
|
let candidates = take(&mut self.candidates).into_inner();
|
||||||
return Ok(Some(CriterionResult {
|
return Ok(Some(CriterionResult {
|
||||||
query_tree: None,
|
query_tree: None,
|
||||||
candidates: take(&mut self.candidates).into_inner(),
|
candidates: candidates.clone(),
|
||||||
bucket_candidates: None,
|
bucket_candidates: Some(candidates),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
(None, Forbidden(_)) => {
|
(None, Forbidden(_)) => {
|
||||||
match self.parent.as_mut() {
|
match self.parent.as_mut() {
|
||||||
Some(parent) => {
|
Some(parent) => {
|
||||||
match parent.next()? {
|
match parent.next()? {
|
||||||
Some(CriterionResult { query_tree, candidates, .. }) => {
|
Some(CriterionResult { query_tree, candidates, bucket_candidates }) => {
|
||||||
self.query_tree = query_tree;
|
self.query_tree = query_tree;
|
||||||
self.candidates = Candidates::Allowed(candidates);
|
self.candidates = Candidates::Allowed(candidates);
|
||||||
|
self.bucket_candidates = bucket_candidates;
|
||||||
},
|
},
|
||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user