Introduce a new invalid_facet_search_facet_name error code

This commit is contained in:
Kerollmops 2023-06-07 11:04:53 +02:00 committed by Louis Dureuil
parent e9a3029c30
commit 41760a9306
No known key found for this signature in database
3 changed files with 6 additions and 3 deletions

View File

@ -233,6 +233,7 @@ InvalidSearchAttributesToRetrieve , InvalidRequest , BAD_REQUEST ;
InvalidSearchCropLength , InvalidRequest , BAD_REQUEST ;
InvalidSearchCropMarker , InvalidRequest , BAD_REQUEST ;
InvalidSearchFacets , InvalidRequest , BAD_REQUEST ;
InvalidFacetSearchFacetName , InvalidRequest , BAD_REQUEST ;
InvalidSearchFilter , InvalidRequest , BAD_REQUEST ;
InvalidSearchHighlightPostTag , InvalidRequest , BAD_REQUEST ;
InvalidSearchHighlightPreTag , InvalidRequest , BAD_REQUEST ;
@ -343,7 +344,9 @@ impl ErrorCode for milli::Error {
UserError::InvalidSearchableAttribute { .. } => {
Code::InvalidAttributesToSearchOn
}
UserError::InvalidSearchFacet { .. } => Code::InvalidSearchFacet,
UserError::InvalidFacetSearchFacetName { .. } => {
Code::InvalidFacetSearchFacetName
}
UserError::CriterionError(_) => Code::InvalidSettingsRankingRules,
UserError::InvalidGeoField { .. } => Code::InvalidDocumentGeoField,
UserError::InvalidVectorDimensions { .. } => Code::InvalidVectorDimensions,

View File

@ -137,7 +137,7 @@ only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and undersco
),
}
)]
InvalidSearchFacet { field: String, valid_fields: BTreeSet<String> },
InvalidFacetSearchFacetName { field: String, valid_fields: BTreeSet<String> },
#[error("Attribute `{}` is not searchable. Available searchable attributes are: `{}{}`.",
.field,
.valid_fields.iter().map(AsRef::as_ref).collect::<Vec<&str>>().join(", "),

View File

@ -264,7 +264,7 @@ impl<'a> SearchForFacetValues<'a> {
let filterable_fields = index.filterable_fields(rtxn)?;
if !filterable_fields.contains(&self.facet) {
return Err(UserError::InvalidSearchFacet {
return Err(UserError::InvalidFacetSearchFacetName {
field: self.facet.clone(),
valid_fields: filterable_fields.into_iter().collect(),
}