Introduce the criteria update setting

This commit is contained in:
Clément Renault 2020-12-04 12:02:22 +01:00
parent f8f33d35e0
commit 61b383f422
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
7 changed files with 181 additions and 34 deletions

View file

@ -243,6 +243,13 @@ struct Settings {
#[serde(default)]
faceted_attributes: Option<HashMap<String, String>>,
#[serde(
default,
deserialize_with = "deserialize_some",
skip_serializing_if = "Option::is_none",
)]
criteria: Option<Option<Vec<String>>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -399,6 +406,14 @@ async fn main() -> anyhow::Result<()> {
builder.set_faceted_fields(facet_types);
}
// We transpose the settings JSON struct into a real setting update.
if let Some(criteria) = settings.criteria {
match criteria {
Some(criteria) => builder.set_criteria(criteria),
None => builder.reset_criteria(),
}
}
let result = builder.execute(|indexing_step| {
let (current, total) = match indexing_step {
TransformFromUserIntoGenericFormat { documents_seen } => (documents_seen, None),