From 01c4f5abcd3ebb28d4a504e770d78de5230e9ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 3 Nov 2020 19:35:55 +0100 Subject: [PATCH] Introduce the searchable attributes setting to the settings route --- src/subcommand/serve.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/subcommand/serve.rs b/src/subcommand/serve.rs index 57cc2e012..dd10607f2 100644 --- a/src/subcommand/serve.rs +++ b/src/subcommand/serve.rs @@ -184,6 +184,13 @@ struct Settings { skip_serializing_if = "Option::is_none", )] displayed_attributes: Option>>, + + #[serde( + default, + deserialize_with = "deserialize_some", + skip_serializing_if = "Option::is_none", + )] + searchable_attributes: Option>>, } // 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 {