add displayed attributes wildcard

This commit is contained in:
mpostma 2020-07-08 21:01:26 +02:00
parent 4262561596
commit 7f5fb50307
2 changed files with 114 additions and 16 deletions

View file

@ -80,7 +80,11 @@ pub fn apply_settings_update(
match settings.searchable_attributes.clone() {
UpdateState::Update(v) => {
schema.update_indexed(v)?;
if v.len() == 1 && v[0] == "*" {
schema.set_all_fields_as_indexed();
} else {
schema.update_indexed(v)?;
}
must_reindex = true;
},
UpdateState::Clear => {
@ -90,7 +94,14 @@ pub fn apply_settings_update(
UpdateState::Nothing => (),
}
match settings.displayed_attributes.clone() {
UpdateState::Update(v) => schema.update_displayed(v)?,
UpdateState::Update(v) => {
// safe to unwrap because len is 1
if v.len() == 1 && v.iter().next().unwrap() == "*" {
schema.set_all_fields_as_displayed();
} else {
schema.update_displayed(v)?
}
},
UpdateState::Clear => {
schema.set_all_fields_as_displayed();
},