diff --git a/meilisearch-http/src/data/mod.rs b/meilisearch-http/src/data/mod.rs index ed5ce4952..15db0e4ae 100644 --- a/meilisearch-http/src/data/mod.rs +++ b/meilisearch-http/src/data/mod.rs @@ -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)), }) } diff --git a/meilisearch-http/src/index_controller/local_index_controller/update_handler.rs b/meilisearch-http/src/index_controller/local_index_controller/update_handler.rs index 5781a2806..ab2e75206 100644 --- a/meilisearch-http/src/index_controller/local_index_controller/update_handler.rs +++ b/meilisearch-http/src/index_controller/local_index_controller/update_handler.rs @@ -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(), diff --git a/meilisearch-http/src/index_controller/mod.rs b/meilisearch-http/src/index_controller/mod.rs index b20e43749..fc8efa036 100644 --- a/meilisearch-http/src/index_controller/mod.rs +++ b/meilisearch-http/src/index_controller/mod.rs @@ -83,7 +83,7 @@ pub struct Settings { deserialize_with = "deserialize_some", skip_serializing_if = "Option::is_none", )] - pub criteria: Option>>, + pub ranking_rules: Option>>, } 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), } } } diff --git a/meilisearch-http/src/routes/settings/mod.rs b/meilisearch-http/src/routes/settings/mod.rs index 00bc4220e..bf6d92133 100644 --- a/meilisearch-http/src/routes/settings/mod.rs +++ b/meilisearch-http/src/routes/settings/mod.rs @@ -103,11 +103,11 @@ make_setting_route!( //distinct_attribute //); -//make_setting_route!( - //"/indexes/{index_uid}/settings/ranking-rules", - //Vec, - //ranking_rules -//); +make_setting_route!( + "/indexes/{index_uid}/settings/ranking-rules", + Vec, + 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")]