From b5b7ec0162bd5c3613f3281cdb29becb1c792758 Mon Sep 17 00:00:00 2001 From: many Date: Wed, 24 Feb 2021 15:59:19 +0100 Subject: [PATCH] implement initial state for words criterion --- milli/src/search/criteria/words.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/milli/src/search/criteria/words.rs b/milli/src/search/criteria/words.rs index cf1668055..bd03ecf97 100644 --- a/milli/src/search/criteria/words.rs +++ b/milli/src/search/criteria/words.rs @@ -60,23 +60,36 @@ impl<'t> Criterion for Words<'t> { self.candidates = Candidates::default(); }, (Some(qt), Allowed(candidates)) => { - let bucket_candidates = match self.parent { - Some(_) => take(&mut self.bucket_candidates), - None => candidates.clone(), - }; - let mut found_candidates = resolve_candidates(self.ctx, &qt, &mut self.candidates_cache)?; found_candidates.intersect_with(&candidates); candidates.difference_with(&found_candidates); + let bucket_candidates = match self.parent { + Some(_) => take(&mut self.bucket_candidates), + None => found_candidates.clone(), + }; + return Ok(Some(CriterionResult { query_tree: Some(qt), candidates: found_candidates, bucket_candidates, })); }, - (Some(_qt), Forbidden(_candidates)) => { - todo!() + (Some(qt), Forbidden(candidates)) => { + let mut found_candidates = resolve_candidates(self.ctx, &qt, &mut self.candidates_cache)?; + found_candidates.difference_with(&candidates); + candidates.union_with(&found_candidates); + + let bucket_candidates = match self.parent { + Some(_) => take(&mut self.bucket_candidates), + None => found_candidates.clone(), + }; + + return Ok(Some(CriterionResult { + query_tree: Some(qt), + candidates: found_candidates, + bucket_candidates, + })); }, (None, Allowed(_)) => { let candidates = take(&mut self.candidates).into_inner();