mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 18:45:06 +08:00
perf: limit reindex to when exact_attributes changes
This commit is contained in:
parent
57c9f03e51
commit
d19c8672bb
@ -1145,9 +1145,8 @@ impl Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Clears the exact attributes from the store.
|
/// Clears the exact attributes from the store.
|
||||||
pub(crate) fn delete_exact_attributes(&self, txn: &mut RwTxn) -> Result<()> {
|
pub(crate) fn delete_exact_attributes(&self, txn: &mut RwTxn) -> Result<bool> {
|
||||||
self.main.delete::<_, Str>(txn, main_key::EXACT_ATTRIBUTES)?;
|
Ok(self.main.delete::<_, Str>(txn, main_key::EXACT_ATTRIBUTES)?)
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn max_values_per_facet(&self, txn: &RoTxn) -> heed::Result<Option<usize>> {
|
pub fn max_values_per_facet(&self, txn: &RoTxn) -> heed::Result<Option<usize>> {
|
||||||
|
@ -465,14 +465,23 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
|
|||||||
fn update_exact_attributes(&mut self) -> Result<bool> {
|
fn update_exact_attributes(&mut self) -> Result<bool> {
|
||||||
match self.exact_attributes {
|
match self.exact_attributes {
|
||||||
Setting::Set(ref attrs) => {
|
Setting::Set(ref attrs) => {
|
||||||
let attrs = attrs.iter().map(String::as_str).collect::<Vec<_>>();
|
let old_attrs = self
|
||||||
self.index.put_exact_attributes(self.wtxn, &attrs)?;
|
.index
|
||||||
Ok(true)
|
.exact_attributes(self.wtxn)?
|
||||||
}
|
.iter()
|
||||||
Setting::Reset => {
|
.cloned()
|
||||||
self.index.delete_exact_attributes(self.wtxn)?;
|
.map(String::from)
|
||||||
Ok(true)
|
.collect::<HashSet<String>>();
|
||||||
|
|
||||||
|
if attrs != &old_attrs {
|
||||||
|
let attrs = attrs.iter().map(String::as_str).collect::<Vec<_>>();
|
||||||
|
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),
|
Setting::NotSet => Ok(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user