diff --git a/milli/src/index.rs b/milli/src/index.rs index 5910a305c..d9636634d 100644 --- a/milli/src/index.rs +++ b/milli/src/index.rs @@ -1145,9 +1145,8 @@ impl Index { } /// Clears the exact attributes from the store. - pub(crate) fn delete_exact_attributes(&self, txn: &mut RwTxn) -> Result<()> { - self.main.delete::<_, Str>(txn, main_key::EXACT_ATTRIBUTES)?; - Ok(()) + pub(crate) fn delete_exact_attributes(&self, txn: &mut RwTxn) -> Result { + Ok(self.main.delete::<_, Str>(txn, main_key::EXACT_ATTRIBUTES)?) } pub fn max_values_per_facet(&self, txn: &RoTxn) -> heed::Result> { diff --git a/milli/src/update/settings.rs b/milli/src/update/settings.rs index 6da32d73f..8220ed3ab 100644 --- a/milli/src/update/settings.rs +++ b/milli/src/update/settings.rs @@ -465,14 +465,23 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> { fn update_exact_attributes(&mut self) -> Result { match self.exact_attributes { Setting::Set(ref attrs) => { - let attrs = attrs.iter().map(String::as_str).collect::>(); - self.index.put_exact_attributes(self.wtxn, &attrs)?; - Ok(true) - } - Setting::Reset => { - self.index.delete_exact_attributes(self.wtxn)?; - Ok(true) + let old_attrs = self + .index + .exact_attributes(self.wtxn)? + .iter() + .cloned() + .map(String::from) + .collect::>(); + + if attrs != &old_attrs { + let attrs = attrs.iter().map(String::as_str).collect::>(); + self.index.put_exact_attributes(self.wtxn, &attrs)?; + Ok(true) + } else { + Ok(false) + } } + Setting::Reset => Ok(self.index.delete_exact_attributes(self.wtxn)?), Setting::NotSet => Ok(false), } }