Update the HTTP settings route to accept the faceted fields

This commit is contained in:
Clément Renault 2020-11-13 16:16:07 +01:00
parent 8e6efe4d87
commit 23f9a22edc
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
2 changed files with 21 additions and 1 deletions

View file

@ -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<Option<Vec<String>>>,
#[serde(default)]
faceted_attributes: Option<HashMap<String, String>>,
}
// 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),