diff --git a/milli/src/update/settings.rs b/milli/src/update/settings.rs index aed2d951e..7d281262a 100644 --- a/milli/src/update/settings.rs +++ b/milli/src/update/settings.rs @@ -349,12 +349,17 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> { fn update_searchable(&mut self) -> Result { match self.searchable_fields { Setting::Set(ref fields) => { - let did_change = self - .index - .searchable_fields(self.wtxn)? - .map(|f| f.into_iter().map(String::from).collect::>()) - .map(|old_fields| fields != &old_fields) - .unwrap_or(true); // if old_fields was None before, it was changed + // Check to see if the searchable fields changed before doing anything else + let old_fields = self.index.searchable_fields(self.wtxn)?; + let did_change = match old_fields { + // If old_fields is Some, let's check to see if the fields actually changed + Some(old_fields) => { + let new_fields = fields.iter().map(String::as_str).collect::>(); + new_fields != old_fields + } + // If old_fields is None, the fields have changed (because they are being set) + None => true, + }; if !did_change { return Ok(false); }