Introduce the searchable attributes setting to the settings route

This commit is contained in:
Clément Renault 2020-11-03 19:35:55 +01:00
parent 63f65bac3e
commit 01c4f5abcd
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -184,6 +184,13 @@ struct Settings {
skip_serializing_if = "Option::is_none",
)]
displayed_attributes: Option<Option<Vec<String>>>,
#[serde(
default,
deserialize_with = "deserialize_some",
skip_serializing_if = "Option::is_none",
)]
searchable_attributes: Option<Option<Vec<String>>>,
}
// Any value that is present is considered Some value, including null.
@ -300,6 +307,14 @@ pub fn run(opt: Opt) -> anyhow::Result<()> {
let mut wtxn = index_cloned.write_txn()?;
let mut builder = update_builder.settings(&mut wtxn, &index_cloned);
// We transpose the settings JSON struct into a real setting update.
if let Some(names) = settings.searchable_attributes {
match names {
Some(names) => builder.set_searchable_fields(names),
None => builder.reset_searchable_fields(),
}
}
// We transpose the settings JSON struct into a real setting update.
if let Some(names) = settings.displayed_attributes {
match names {