Make sure we don't crash on unreferenced fields

This commit is contained in:
Clément Renault
2025-11-18 17:03:27 +01:00
committed by Kerollmops
parent 5d94d82d1f
commit c8ed1158c4

View File

@@ -509,8 +509,9 @@ where
let new_searchable_attributes = settings_delta.new_searchable_attributes().as_ref();
old_searchable_attributes.zip(new_searchable_attributes).map(|(old, new)| {
old.iter()
.filter(|field_name| !new.contains(field_name))
.map(|field_name| fields_ids_map.id(field_name).unwrap())
// Ignore the field if it is not searchable anymore
// or if it was never referenced in any document
.filter_map(|name| if new.contains(name) { None } else { fields_ids_map.id(name) })
.collect()
})
};