enable criterion setting

This commit is contained in:
mpostma 2021-03-05 19:31:49 +01:00
parent b8ebf07555
commit 65ca80bdde
No known key found for this signature in database
GPG Key ID: CBC8A7C1D7A28C3A
4 changed files with 17 additions and 10 deletions

View File

@ -106,11 +106,17 @@ impl Data {
.map(|(k, v)| (k, v.to_string()))
.collect();
let criteria = index
.criteria(&txn)?
.into_iter()
.map(|v| format!("{:?}", v))
.collect();
Ok(Settings {
displayed_attributes: Some(Some(displayed_attributes)),
searchable_attributes: Some(Some(searchable_attributes)),
faceted_attributes: Some(Some(faceted_attributes)),
criteria: None,
ranking_rules: Some(Some(criteria)),
})
}

View File

@ -153,7 +153,7 @@ impl UpdateHandler {
}
// We transpose the settings JSON struct into a real setting update.
if let Some(ref criteria) = settings.criteria {
if let Some(ref criteria) = settings.ranking_rules {
match criteria {
Some(criteria) => builder.set_criteria(criteria.clone()),
None => builder.reset_criteria(),

View File

@ -83,7 +83,7 @@ pub struct Settings {
deserialize_with = "deserialize_some",
skip_serializing_if = "Option::is_none",
)]
pub criteria: Option<Option<Vec<String>>>,
pub ranking_rules: Option<Option<Vec<String>>>,
}
impl Settings {
@ -92,7 +92,7 @@ impl Settings {
displayed_attributes: Some(None),
searchable_attributes: Some(None),
faceted_attributes: Some(None),
criteria: Some(None),
ranking_rules: Some(None),
}
}
}

View File

@ -103,11 +103,11 @@ make_setting_route!(
//distinct_attribute
//);
//make_setting_route!(
//"/indexes/{index_uid}/settings/ranking-rules",
//Vec<String>,
//ranking_rules
//);
make_setting_route!(
"/indexes/{index_uid}/settings/ranking-rules",
Vec<String>,
ranking_rules
);
macro_rules! create_services {
($($mod:ident),*) => {
@ -128,7 +128,8 @@ macro_rules! create_services {
create_services!(
faceted_attributes,
displayed_attributes,
searchable_attributes
searchable_attributes,
ranking_rules
);
#[post("/indexes/{index_uid}/settings", wrap = "Authentication::Private")]