From 23f9a22edc24499bcfd48a42197a980052f68ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Fri, 13 Nov 2020 16:16:07 +0100 Subject: [PATCH] Update the HTTP settings route to accept the faceted fields --- http-ui/Cargo.lock | 10 ++++++++++ http-ui/src/main.rs | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/http-ui/Cargo.lock b/http-ui/Cargo.lock index 7c7759e2e..23fed5bbe 100644 --- a/http-ui/Cargo.lock +++ b/http-ui/Cargo.lock @@ -989,6 +989,7 @@ dependencies = [ "near-proximity", "obkv", "once_cell", + "ordered-float", "rayon", "ringtail", "roaring", @@ -1205,6 +1206,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "ordered-float" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fe9037165d7023b1228bc4ae9a2fa1a2b0095eca6c2998c624723dfd01314a5" +dependencies = [ + "num-traits", +] + [[package]] name = "page_size" version = "0.4.2" diff --git a/http-ui/src/main.rs b/http-ui/src/main.rs index 2af2c9d90..094b2fb79 100644 --- a/http-ui/src/main.rs +++ b/http-ui/src/main.rs @@ -1,5 +1,5 @@ use std::borrow::Cow; -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; use std::fs::{File, create_dir_all}; use std::net::SocketAddr; use std::path::PathBuf; @@ -210,6 +210,8 @@ enum UpdateMetaProgress { } #[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "camelCase")] struct Settings { #[serde( default, @@ -224,6 +226,9 @@ struct Settings { skip_serializing_if = "Option::is_none", )] searchable_attributes: Option>>, + + #[serde(default)] + faceted_attributes: Option>, } // Any value that is present is considered Some value, including null. @@ -367,6 +372,11 @@ async fn main() -> anyhow::Result<()> { } } + // We transpose the settings JSON struct into a real setting update. + if let Some(facet_types) = settings.faceted_attributes { + builder.set_faceted_fields(facet_types); + } + let result = builder.execute(|indexing_step| { let (current, total) = match indexing_step { TransformFromUserIntoGenericFormat { documents_seen } => (documents_seen, None),