default attributes_for_faceting to []

This commit is contained in:
mpostma 2020-06-03 10:32:42 +02:00
parent 8f0d9ccd87
commit ed051b65ad

View File

@ -95,15 +95,17 @@ async fn get_all(
let attributes_for_faceting = match (&schema, &index.main.attributes_for_faceting(&reader)?) { let attributes_for_faceting = match (&schema, &index.main.attributes_for_faceting(&reader)?) {
(Some(schema), Some(attrs)) => { (Some(schema), Some(attrs)) => {
Some(attrs attrs
.iter() .iter()
.filter_map(|&id| schema.name(id)) .filter_map(|&id| schema.name(id))
.map(str::to_string) .map(str::to_string)
.collect()) .collect()
} }
_ => None, _ => vec![],
}; };
println!("{:?}", attributes_for_faceting);
let searchable_attributes = schema.clone().map(|s| { let searchable_attributes = schema.clone().map(|s| {
s.indexed_name() s.indexed_name()
.iter() .iter()
@ -128,7 +130,7 @@ async fn get_all(
stop_words: Some(Some(stop_words)), stop_words: Some(Some(stop_words)),
synonyms: Some(Some(synonyms)), synonyms: Some(Some(synonyms)),
accept_new_fields: Some(accept_new_fields), 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)) Ok(HttpResponse::Ok().json(settings))
@ -500,18 +502,18 @@ async fn get_attributes_for_faceting(
let attributes_for_faceting = data let attributes_for_faceting = data
.db .db
.main_read::<_, Option<Vec<String>>, ResponseError>(|reader| { .main_read::<_, _, ResponseError>(|reader| {
let schema = index.main.schema(reader)?; let schema = index.main.schema(reader)?;
let attrs = index.main.attributes_for_faceting(reader)?; let attrs = index.main.attributes_for_faceting(reader)?;
let attr_names = match (&schema, &attrs) { let attr_names = match (&schema, &attrs) {
(Some(schema), Some(attrs)) => { (Some(schema), Some(attrs)) => {
Some(attrs attrs
.iter() .iter()
.filter_map(|&id| schema.name(id)) .filter_map(|&id| schema.name(id))
.map(str::to_string) .map(str::to_string)
.collect()) .collect()
} }
_ => None, _ => vec![]
}; };
Ok(attr_names) Ok(attr_names)
})?; })?;