mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-30 23:46:28 +00:00 
			
		
		
		
	Improve the returned errors from the facet-search route
This commit is contained in:
		
				
					committed by
					
						 Louis Dureuil
						Louis Dureuil
					
				
			
			
				
	
			
			
			
						parent
						
							a05074e675
						
					
				
				
					commit
					702041b7e1
				
			| @@ -128,6 +128,16 @@ only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and undersco | ||||
|         } | ||||
|     )] | ||||
|     InvalidSortableAttribute { field: String, valid_fields: BTreeSet<String> }, | ||||
|     #[error("Attribute `{}` is not filterable. {}", | ||||
|         .field, | ||||
|         match .valid_fields.is_empty() { | ||||
|             true => "This index does not have configured filterable attributes.".to_string(), | ||||
|             false => format!("Available filterable attributes are: `{}`.", | ||||
|                     valid_fields.iter().map(AsRef::as_ref).collect::<Vec<&str>>().join(", ") | ||||
|                 ), | ||||
|         } | ||||
|     )] | ||||
|     InvalidSearchFacet { 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(", "), | ||||
|   | ||||
| @@ -263,8 +263,7 @@ impl<'a> SearchForFacetValue<'a> { | ||||
|  | ||||
|         let filterable_fields = index.filterable_fields(rtxn)?; | ||||
|         if !filterable_fields.contains(&self.facet) { | ||||
|             // TODO create a new type of error | ||||
|             return Err(UserError::InvalidSortableAttribute { | ||||
|             return Err(UserError::InvalidSearchFacet { | ||||
|                 field: self.facet.clone(), | ||||
|                 valid_fields: filterable_fields.into_iter().collect(), | ||||
|             })?; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user