From c5164c01c068a8f1e922f26837fa4b3fb3be94f3 Mon Sep 17 00:00:00 2001 From: Tamo Date: Thu, 28 Oct 2021 12:34:39 +0200 Subject: [PATCH] set the total of sortable attributes and filterable-attributes to 0 when not set --- meilisearch-http/src/routes/indexes/settings.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/meilisearch-http/src/routes/indexes/settings.rs b/meilisearch-http/src/routes/indexes/settings.rs index 327752da6..65b1a9a4b 100644 --- a/meilisearch-http/src/routes/indexes/settings.rs +++ b/meilisearch-http/src/routes/indexes/settings.rs @@ -99,7 +99,7 @@ make_setting_route!( analytics.publish( "FilterableAttributes Updated".to_string(), json!({ - "total": setting.as_ref().map(|filter| filter.len()), + "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,7 +119,7 @@ make_setting_route!( analytics.publish( "SortableAttributes Updated".to_string(), json!({ - "total": setting.as_ref().map(|sort| sort.len()), + "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), @@ -221,11 +221,11 @@ pub async fn update_all( "sort_position": settings.ranking_rules.as_ref().set().map(|sort| sort.iter().position(|s| s == "sort")), }, "sortable_attributes": { - "total": settings.sortable_attributes.as_ref().set().map(|sort| sort.len()), + "total": settings.sortable_attributes.as_ref().set().map(|sort| sort.len()).unwrap_or(0), "has_geo": settings.sortable_attributes.as_ref().set().map(|sort| sort.iter().any(|s| s == "_geo")).unwrap_or(false), }, "filterable_attributes": { - "total": settings.filterable_attributes.as_ref().set().map(|filter| filter.len()), + "total": settings.filterable_attributes.as_ref().set().map(|filter| filter.len()).unwrap_or(0), "has_geo": settings.filterable_attributes.as_ref().set().map(|filter| filter.iter().any(|s| s == "_geo")).unwrap_or(false), }, }),