From ed051b65adeebae8805cefc5e2c1734dbe4a62e2 Mon Sep 17 00:00:00 2001 From: mpostma Date: Wed, 3 Jun 2020 10:32:42 +0200 Subject: [PATCH] default attributes_for_faceting to [] --- meilisearch-http/src/routes/setting.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/meilisearch-http/src/routes/setting.rs b/meilisearch-http/src/routes/setting.rs index 46268694d..37fe5bda2 100644 --- a/meilisearch-http/src/routes/setting.rs +++ b/meilisearch-http/src/routes/setting.rs @@ -95,15 +95,17 @@ async fn get_all( let attributes_for_faceting = match (&schema, &index.main.attributes_for_faceting(&reader)?) { (Some(schema), Some(attrs)) => { - Some(attrs + attrs .iter() .filter_map(|&id| schema.name(id)) .map(str::to_string) - .collect()) + .collect() } - _ => None, + _ => vec![], }; + println!("{:?}", attributes_for_faceting); + let searchable_attributes = schema.clone().map(|s| { s.indexed_name() .iter() @@ -128,7 +130,7 @@ async fn get_all( stop_words: Some(Some(stop_words)), synonyms: Some(Some(synonyms)), accept_new_fields: Some(accept_new_fields), - attributes_for_faceting: Some(attributes_for_faceting), + attributes_for_faceting: Some(Some(attributes_for_faceting)), }; Ok(HttpResponse::Ok().json(settings)) @@ -500,18 +502,18 @@ async fn get_attributes_for_faceting( let attributes_for_faceting = data .db - .main_read::<_, Option>, ResponseError>(|reader| { + .main_read::<_, _, ResponseError>(|reader| { let schema = index.main.schema(reader)?; let attrs = index.main.attributes_for_faceting(reader)?; let attr_names = match (&schema, &attrs) { (Some(schema), Some(attrs)) => { - Some(attrs + attrs .iter() .filter_map(|&id| schema.name(id)) .map(str::to_string) - .collect()) + .collect() } - _ => None, + _ => vec![] }; Ok(attr_names) })?;