mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-05-17 17:53:57 +02:00
refactor: update error message format for filterable attributes
This commit is contained in:
parent
041f635214
commit
15db203b7d
2188
Cargo.lock
generated
2188
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -441,42 +441,49 @@ fn format_invalid_filter_distribution(
|
|||||||
invalid_facets_name: &BTreeSet<String>,
|
invalid_facets_name: &BTreeSet<String>,
|
||||||
valid_patterns: &BTreeSet<String>,
|
valid_patterns: &BTreeSet<String>,
|
||||||
) -> String {
|
) -> String {
|
||||||
|
let mut result = String::new();
|
||||||
|
|
||||||
|
if invalid_facets_name.is_empty() {
|
||||||
if valid_patterns.is_empty() {
|
if valid_patterns.is_empty() {
|
||||||
return "this index does not have configured filterable attributes.".into();
|
return "this index does not have configured filterable attributes.".into();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
let mut result = String::new();
|
|
||||||
|
|
||||||
match invalid_facets_name.len() {
|
match invalid_facets_name.len() {
|
||||||
0 => (),
|
|
||||||
1 => write!(
|
1 => write!(
|
||||||
result,
|
result,
|
||||||
"attribute `{}` is not filterable.",
|
"Attribute `{}` is not filterable.",
|
||||||
invalid_facets_name.first().unwrap()
|
invalid_facets_name.first().unwrap()
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
_ => write!(
|
_ => write!(
|
||||||
result,
|
result,
|
||||||
"attributes `{}` are not filterable.",
|
"Attributes `{}` are not filterable.",
|
||||||
invalid_facets_name.iter().map(AsRef::as_ref).collect::<Vec<&str>>().join(", ")
|
invalid_facets_name.iter().map(AsRef::as_ref).collect::<Vec<&str>>().join(", ")
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if valid_patterns.is_empty() {
|
||||||
|
if !invalid_facets_name.is_empty() {
|
||||||
|
write!(result, " This index does not have configured filterable attributes.").unwrap();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
match valid_patterns.len() {
|
match valid_patterns.len() {
|
||||||
1 => write!(
|
1 => write!(
|
||||||
result,
|
result,
|
||||||
" The available filterable attribute pattern is `{}`.",
|
" Available filterable attributes patterns are: `{}`.",
|
||||||
valid_patterns.first().unwrap()
|
valid_patterns.first().unwrap()
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
_ => write!(
|
_ => write!(
|
||||||
result,
|
result,
|
||||||
" The available filterable attribute patterns are `{}`.",
|
" Available filterable attributes patterns are: `{}`.",
|
||||||
valid_patterns.iter().map(AsRef::as_ref).collect::<Vec<&str>>().join(", ")
|
valid_patterns.iter().map(AsRef::as_ref).collect::<Vec<&str>>().join(", ")
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user