mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-28 01:01:00 +00:00
fix the searchable fields bug when a field is nested
Update milli/src/index.rs Co-authored-by: Clément Renault <clement@meilisearch.com>
This commit is contained in:
@ -157,6 +157,18 @@ where
|
||||
let new_facets = output.compute_real_facets(self.wtxn, self.index)?;
|
||||
self.index.put_faceted_fields(self.wtxn, &new_facets)?;
|
||||
|
||||
// in case new fields were introduced we're going to recreate the searchable fields.
|
||||
if let Some(faceted_fields) = self.index.user_defined_searchable_fields(self.wtxn)? {
|
||||
// we can't keep references on the faceted fields while we update the index thus we need to own it.
|
||||
let faceted_fields: Vec<String> =
|
||||
faceted_fields.into_iter().map(str::to_string).collect();
|
||||
self.index.put_all_searchable_fields_from_fields_ids_map(
|
||||
self.wtxn,
|
||||
&faceted_fields.iter().map(String::as_ref).collect::<Vec<_>>(),
|
||||
&output.fields_ids_map,
|
||||
)?;
|
||||
}
|
||||
|
||||
let indexed_documents = output.documents_count as u64;
|
||||
let number_of_documents = self.execute_raw(output)?;
|
||||
|
||||
|
@ -343,11 +343,15 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
|
||||
new_fields_ids_map.insert(&name).ok_or(UserError::AttributeLimitReached)?;
|
||||
}
|
||||
|
||||
self.index.put_searchable_fields(self.wtxn, &names)?;
|
||||
self.index.put_all_searchable_fields_from_fields_ids_map(
|
||||
self.wtxn,
|
||||
&names,
|
||||
&new_fields_ids_map,
|
||||
)?;
|
||||
self.index.put_fields_ids_map(self.wtxn, &new_fields_ids_map)?;
|
||||
}
|
||||
Setting::Reset => {
|
||||
self.index.delete_searchable_fields(self.wtxn)?;
|
||||
self.index.delete_all_searchable_fields(self.wtxn)?;
|
||||
}
|
||||
Setting::NotSet => return Ok(false),
|
||||
}
|
||||
|
Reference in New Issue
Block a user