mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-04-18 07:57:59 +02:00
Fix: Add #[allow(dead_code)] to format_invalid_filter_distribution function
This commit is contained in:
parent
91d221ebe7
commit
041f635214
@ -125,21 +125,21 @@ and can not be more than 511 bytes.", .document_id.to_string()
|
|||||||
if .invalid_facets_name.len() == 1 {
|
if .invalid_facets_name.len() == 1 {
|
||||||
let field = .invalid_facets_name.iter().next().unwrap();
|
let field = .invalid_facets_name.iter().next().unwrap();
|
||||||
match .matching_rule_indices.get(field) {
|
match .matching_rule_indices.get(field) {
|
||||||
Some(rule_index) => format!("Attribute `{}` matched rule #{} in filterableAttributes, but this rule does not enable filtering.\nHint: enable filtering in rule #{} by modifying the features.filter object\nHint: prepend another rule matching `{}` with appropriate filter features before rule #{}",
|
Some(rule_index) => format!("Attribute `{}` matched rule #{} in filterableAttributes, but this rule does not enable filtering.\nHint: enable filtering in rule #{} by modifying the features.filter object\nHint: prepend another rule matching `{}` with appropriate filter features before rule #{}",
|
||||||
field, rule_index, rule_index, field, rule_index),
|
field, rule_index, rule_index, field, rule_index),
|
||||||
None => match .valid_patterns.is_empty() {
|
None => match .valid_patterns.is_empty() {
|
||||||
true => format!("Attribute `{}` is not filterable. This index does not have configured filterable attributes.", field),
|
true => format!("Attribute `{}` is not filterable. This index does not have configured filterable attributes.", field),
|
||||||
false => format!("Attribute `{}` is not filterable. Available filterable attributes patterns are: `{}`.",
|
false => format!("Attribute `{}` is not filterable. Available filterable attributes patterns are: `{}`.",
|
||||||
field,
|
field,
|
||||||
.valid_patterns.iter().map(AsRef::as_ref).collect::<Vec<&str>>().join(", ")),
|
.valid_patterns.iter().map(AsRef::as_ref).collect::<Vec<&str>>().join(", ")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
format!("Attributes `{}` are not filterable. {}",
|
format!("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(", "),
|
||||||
match .valid_patterns.is_empty() {
|
match .valid_patterns.is_empty() {
|
||||||
true => "This index does not have configured filterable attributes.".to_string(),
|
true => "This index does not have configured filterable attributes.".to_string(),
|
||||||
false => format!("Available filterable attributes patterns are: `{}`.",
|
false => format!("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(", ")),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -162,10 +162,10 @@ and can not be more than 511 bytes.", .document_id.to_string()
|
|||||||
InvalidFilter(String),
|
InvalidFilter(String),
|
||||||
#[error("Invalid type for filter subexpression: expected: {}, found: {}.", .0.join(", "), .1)]
|
#[error("Invalid type for filter subexpression: expected: {}, found: {}.", .0.join(", "), .1)]
|
||||||
InvalidFilterExpression(&'static [&'static str], Value),
|
InvalidFilterExpression(&'static [&'static str], Value),
|
||||||
#[error("Filter operator `{operator}` is not allowed for the attribute `{field}`.\n - Note: allowed operators: {}.\n - Note: field `{field}` matched rule #{rule_index} in `filterableAttributes`\n - Hint: enable {} in rule #{rule_index} by modifying the features.filter object\n - Hint: prepend another rule matching `{field}` with appropriate filter features before rule #{rule_index}",
|
#[error("Filter operator `{operator}` is not allowed for the attribute `{field}`.\n - Note: allowed operators: {}.\n - Note: field `{field}` matched rule #{rule_index} in `filterableAttributes`\n - Hint: enable {} in rule #{rule_index} by modifying the features.filter object\n - Hint: prepend another rule matching `{field}` with appropriate filter features before rule #{rule_index}",
|
||||||
allowed_operators.join(", "),
|
allowed_operators.join(", "),
|
||||||
if operator == "=" || operator == "!=" || operator == "IN" {"equality"}
|
if operator == "=" || operator == "!=" || operator == "IN" {"equality"}
|
||||||
else if operator == "<" || operator == ">" || operator == "<=" || operator == ">=" || operator == "TO" {"comparison"}
|
else if operator == "<" || operator == ">" || operator == "<=" || operator == ">=" || operator == "TO" {"comparison"}
|
||||||
else {"the appropriate filter operators"}
|
else {"the appropriate filter operators"}
|
||||||
)]
|
)]
|
||||||
FilterOperatorNotAllowed {
|
FilterOperatorNotAllowed {
|
||||||
@ -190,13 +190,13 @@ and can not be more than 511 bytes.", .document_id.to_string()
|
|||||||
match (.valid_patterns.is_empty(), .matching_rule_index) {
|
match (.valid_patterns.is_empty(), .matching_rule_index) {
|
||||||
// No rules match and no filterable attributes
|
// No rules match and no filterable attributes
|
||||||
(true, None) => "This index does not have configured filterable attributes.".to_string(),
|
(true, None) => "This index does not have configured filterable attributes.".to_string(),
|
||||||
|
|
||||||
// No rules match but there are some filterable attributes
|
// No rules match but there are some filterable attributes
|
||||||
(false, None) => format!("Available filterable attributes patterns are: `{}{}`.",
|
(false, None) => format!("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(", "),
|
||||||
.hidden_fields.then_some(", <..hidden-attributes>").unwrap_or(""),
|
.hidden_fields.then_some(", <..hidden-attributes>").unwrap_or(""),
|
||||||
),
|
),
|
||||||
|
|
||||||
// A rule matched but filtering isn't enabled
|
// A rule matched but filtering isn't enabled
|
||||||
(_, Some(rule_index)) => format!("Note: this attribute matches rule #{} in filterableAttributes, but this rule does not enable filtering.\nHint: enable filtering in rule #{} by adding appropriate filter features.\nHint: prepend another rule matching {} with filter features before rule #{}",
|
(_, Some(rule_index)) => format!("Note: this attribute matches rule #{} in filterableAttributes, but this rule does not enable filtering.\nHint: enable filtering in rule #{} by adding appropriate filter features.\nHint: prepend another rule matching {} with filter features before rule #{}",
|
||||||
rule_index, rule_index, .field, rule_index
|
rule_index, rule_index, .field, rule_index
|
||||||
@ -214,13 +214,13 @@ and can not be more than 511 bytes.", .document_id.to_string()
|
|||||||
match (.valid_patterns.is_empty(), .matching_rule_index) {
|
match (.valid_patterns.is_empty(), .matching_rule_index) {
|
||||||
// No rules match and no facet searchable attributes
|
// No rules match and no facet searchable attributes
|
||||||
(true, None) => "This index does not have configured facet-searchable attributes. To make it facet-searchable add it to the `filterableAttributes` index settings.".to_string(),
|
(true, None) => "This index does not have configured facet-searchable attributes. To make it facet-searchable add it to the `filterableAttributes` index settings.".to_string(),
|
||||||
|
|
||||||
// No rules match but there are some facet searchable attributes
|
// No rules match but there are some facet searchable attributes
|
||||||
(false, None) => format!("Available facet-searchable attributes patterns are: `{}{}`. To make it facet-searchable add it to the `filterableAttributes` index settings.",
|
(false, None) => format!("Available facet-searchable attributes patterns are: `{}{}`. To make it facet-searchable add it to the `filterableAttributes` index settings.",
|
||||||
valid_patterns.iter().map(AsRef::as_ref).collect::<Vec<&str>>().join(", "),
|
valid_patterns.iter().map(AsRef::as_ref).collect::<Vec<&str>>().join(", "),
|
||||||
.hidden_fields.then_some(", <..hidden-attributes>").unwrap_or(""),
|
.hidden_fields.then_some(", <..hidden-attributes>").unwrap_or(""),
|
||||||
),
|
),
|
||||||
|
|
||||||
// A rule matched but facet search isn't enabled
|
// A rule matched but facet search isn't enabled
|
||||||
(_, Some(rule_index)) => format!("Note: this attribute matches rule #{} in filterableAttributes, but this rule does not enable facetSearch.\nHint: enable facetSearch in rule #{} by adding `\"facetSearch\": true` to the rule.\nHint: prepend another rule matching {} with facetSearch: true before rule #{}",
|
(_, Some(rule_index)) => format!("Note: this attribute matches rule #{} in filterableAttributes, but this rule does not enable facetSearch.\nHint: enable facetSearch in rule #{} by adding `\"facetSearch\": true` to the rule.\nHint: prepend another rule matching {} with facetSearch: true before rule #{}",
|
||||||
rule_index, rule_index, .field, rule_index
|
rule_index, rule_index, .field, rule_index
|
||||||
@ -436,6 +436,7 @@ pub enum GeoError {
|
|||||||
BadLongitude { document_id: Value, value: Value },
|
BadLongitude { document_id: Value, value: Value },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn format_invalid_filter_distribution(
|
fn format_invalid_filter_distribution(
|
||||||
invalid_facets_name: &BTreeSet<String>,
|
invalid_facets_name: &BTreeSet<String>,
|
||||||
valid_patterns: &BTreeSet<String>,
|
valid_patterns: &BTreeSet<String>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user