From 0a9bd398c7f52bce0b8dde30b9a8ddd7411dbb20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 5 Jun 2024 16:59:00 -0400 Subject: [PATCH] Improve the NOT operator to use the universe when possible --- milli/src/search/facet/filter.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/milli/src/search/facet/filter.rs b/milli/src/search/facet/filter.rs index d75ed5f22..4570d4ca4 100644 --- a/milli/src/search/facet/filter.rs +++ b/milli/src/search/facet/filter.rs @@ -349,8 +349,6 @@ impl<'a> Filter<'a> { match &self.condition { FilterCondition::Not(f) => { - // TODO improve the documents_ids to also support intersections at deserialize time. - let all_ids = index.documents_ids(rtxn)?; let selected = Self::inner_evaluate( &(f.as_ref().clone()).into(), rtxn, @@ -358,7 +356,13 @@ impl<'a> Filter<'a> { filterable_fields, universe, )?; - Ok(all_ids - selected) + match universe { + Some(universe) => Ok(universe - selected), + None => { + let all_ids = index.documents_ids(rtxn)?; + Ok(all_ids - selected) + } + } } FilterCondition::In { fid, els } => { if crate::is_faceted(fid.value(), filterable_fields) {