From 6ef73eb2262e12ad84ea7df26735954969afb342 Mon Sep 17 00:00:00 2001 From: Tamo Date: Thu, 28 Oct 2021 13:02:48 +0200 Subject: [PATCH] fix all the single settings route and add the searchable attributes Updated event --- .../src/routes/indexes/settings.rs | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/meilisearch-http/src/routes/indexes/settings.rs b/meilisearch-http/src/routes/indexes/settings.rs index 65b1a9a4b..4cb939f79 100644 --- a/meilisearch-http/src/routes/indexes/settings.rs +++ b/meilisearch-http/src/routes/indexes/settings.rs @@ -99,8 +99,10 @@ make_setting_route!( analytics.publish( "FilterableAttributes Updated".to_string(), json!({ - "total": setting.as_ref().map(|filter| filter.len()).unwrap_or(0), - "has_geo": setting.as_ref().map(|filter| filter.contains("_geo")).unwrap_or(false), + "filterable_attributes": { + "total": setting.as_ref().map(|filter| filter.len()).unwrap_or(0), + "has_geo": setting.as_ref().map(|filter| filter.contains("_geo")).unwrap_or(false), + } }), Some(req), ); @@ -119,8 +121,10 @@ make_setting_route!( analytics.publish( "SortableAttributes Updated".to_string(), json!({ - "total": setting.as_ref().map(|sort| sort.len()).unwrap_or(0), - "has_geo": setting.as_ref().map(|sort| sort.contains("_geo")).unwrap_or(false), + "sortable_attributes": { + "total": setting.as_ref().map(|sort| sort.len()).unwrap_or(0), + "has_geo": setting.as_ref().map(|sort| sort.contains("_geo")).unwrap_or(false), + }, }), Some(req), ); @@ -138,7 +142,21 @@ make_setting_route!( "/searchable-attributes", Vec, searchable_attributes, - "searchableAttributes" + "searchableAttributes", + analytics, + |setting: &Option>, req: &HttpRequest| { + use serde_json::json; + + analytics.publish( + "SearchableAttributes Updated".to_string(), + json!({ + "searchable_attributes": { + "total": setting.as_ref().map(|sort| sort.len()).unwrap_or(0), + }, + }), + Some(req), + ); + } ); make_setting_route!(