mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-29 23:16:26 +00:00 
			
		
		
		
	return an error when _geoPoint is used but _geo is not sortable
This commit is contained in:
		| @@ -20,7 +20,7 @@ pub use self::matching_words::MatchingWords; | ||||
| use self::query_tree::QueryTreeBuilder; | ||||
| use crate::error::UserError; | ||||
| use crate::search::criteria::r#final::{Final, FinalResult}; | ||||
| use crate::{AscDesc, Criterion, DocumentId, Index, Result}; | ||||
| use crate::{AscDesc, Criterion, DocumentId, Index, Member, Result}; | ||||
|  | ||||
| // Building these factories is not free. | ||||
| static LEVDIST0: Lazy<LevBuilder> = Lazy::new(|| LevBuilder::new(0, true)); | ||||
| @@ -147,15 +147,20 @@ impl<'a> Search<'a> { | ||||
|         if let Some(sort_criteria) = &self.sort_criteria { | ||||
|             let sortable_fields = self.index.sortable_fields(self.rtxn)?; | ||||
|             for asc_desc in sort_criteria { | ||||
|                 // we are not supposed to find any geoPoint in the criterion | ||||
|                 if let Some(field) = asc_desc.field() { | ||||
|                     if !sortable_fields.contains(field) { | ||||
|                 match asc_desc.member() { | ||||
|                     Member::Field(ref field) if !sortable_fields.contains(field) => { | ||||
|                         return Err(UserError::InvalidSortableAttribute { | ||||
|                             field: field.to_string(), | ||||
|                             valid_fields: sortable_fields, | ||||
|                         } | ||||
|                         .into()); | ||||
|                         })? | ||||
|                     } | ||||
|                     Member::Geo(_) if !sortable_fields.contains("_geo") => { | ||||
|                         return Err(UserError::InvalidSortableAttribute { | ||||
|                             field: "_geo".to_string(), | ||||
|                             valid_fields: sortable_fields, | ||||
|                         })? | ||||
|                     } | ||||
|                     _ => (), | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user