mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-11 15:38:55 +01:00
reset value of searchable and displayed attributes; fix #473
This commit is contained in:
parent
aa95c26e07
commit
79e07fa852
@ -84,8 +84,7 @@ pub fn apply_settings_update(
|
|||||||
must_reindex = true;
|
must_reindex = true;
|
||||||
},
|
},
|
||||||
UpdateState::Clear => {
|
UpdateState::Clear => {
|
||||||
let clear: Vec<&str> = Vec::new();
|
schema.set_all_fields_indexed();
|
||||||
schema.update_indexed(clear)?;
|
|
||||||
must_reindex = true;
|
must_reindex = true;
|
||||||
},
|
},
|
||||||
UpdateState::Nothing => (),
|
UpdateState::Nothing => (),
|
||||||
@ -93,8 +92,7 @@ pub fn apply_settings_update(
|
|||||||
match settings.displayed_attributes.clone() {
|
match settings.displayed_attributes.clone() {
|
||||||
UpdateState::Update(v) => schema.update_displayed(v)?,
|
UpdateState::Update(v) => schema.update_displayed(v)?,
|
||||||
UpdateState::Clear => {
|
UpdateState::Clear => {
|
||||||
let clear: Vec<&str> = Vec::new();
|
schema.set_all_fields_displayed();
|
||||||
schema.update_displayed(clear)?;
|
|
||||||
},
|
},
|
||||||
UpdateState::Nothing => (),
|
UpdateState::Nothing => (),
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::collections::hash_map::Iter;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -45,7 +46,12 @@ impl FieldsMap {
|
|||||||
pub fn name<I: Into<FieldId>>(&self, id: I) -> Option<&str> {
|
pub fn name<I: Into<FieldId>>(&self, id: I) -> Option<&str> {
|
||||||
self.id_map.get(&id.into()).map(|s| s.as_str())
|
self.id_map.get(&id.into()).map(|s| s.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn iter(&self) -> Iter<'_, String, FieldId> {
|
||||||
|
self.name_map.iter()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
@ -190,6 +190,25 @@ impl Schema {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_all_fields_indexed(&mut self) {
|
||||||
|
self.indexed.clear();
|
||||||
|
self.indexed_map.clear();
|
||||||
|
|
||||||
|
for (_name, id) in self.fields_map.iter() {
|
||||||
|
let pos = self.indexed.len() as u16;
|
||||||
|
self.indexed.push(*id);
|
||||||
|
self.indexed_map.insert(*id, pos.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_all_fields_displayed(&mut self) {
|
||||||
|
self.displayed.clear();
|
||||||
|
|
||||||
|
for (_name, id) in self.fields_map.iter() {
|
||||||
|
self.displayed.insert(*id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn accept_new_fields(&self) -> bool {
|
pub fn accept_new_fields(&self) -> bool {
|
||||||
self.accept_new_fields
|
self.accept_new_fields
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user