mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 00:55:00 +08:00
enable criterion setting
This commit is contained in:
parent
b8ebf07555
commit
65ca80bdde
@ -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)),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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")]
|
||||
|
Loading…
Reference in New Issue
Block a user