mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-25 06:00:08 +01:00
return an error when _geoPoint is used but _geo is not sortable
This commit is contained in:
parent
1e5e3d57e2
commit
47ee93b0bd
@ -20,7 +20,7 @@ pub use self::matching_words::MatchingWords;
|
|||||||
use self::query_tree::QueryTreeBuilder;
|
use self::query_tree::QueryTreeBuilder;
|
||||||
use crate::error::UserError;
|
use crate::error::UserError;
|
||||||
use crate::search::criteria::r#final::{Final, FinalResult};
|
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.
|
// Building these factories is not free.
|
||||||
static LEVDIST0: Lazy<LevBuilder> = Lazy::new(|| LevBuilder::new(0, true));
|
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 {
|
if let Some(sort_criteria) = &self.sort_criteria {
|
||||||
let sortable_fields = self.index.sortable_fields(self.rtxn)?;
|
let sortable_fields = self.index.sortable_fields(self.rtxn)?;
|
||||||
for asc_desc in sort_criteria {
|
for asc_desc in sort_criteria {
|
||||||
// we are not supposed to find any geoPoint in the criterion
|
match asc_desc.member() {
|
||||||
if let Some(field) = asc_desc.field() {
|
Member::Field(ref field) if !sortable_fields.contains(field) => {
|
||||||
if !sortable_fields.contains(field) {
|
|
||||||
return Err(UserError::InvalidSortableAttribute {
|
return Err(UserError::InvalidSortableAttribute {
|
||||||
field: field.to_string(),
|
field: field.to_string(),
|
||||||
valid_fields: sortable_fields,
|
valid_fields: sortable_fields,
|
||||||
}
|
})?
|
||||||
.into());
|
|
||||||
}
|
}
|
||||||
|
Member::Geo(_) if !sortable_fields.contains("_geo") => {
|
||||||
|
return Err(UserError::InvalidSortableAttribute {
|
||||||
|
field: "_geo".to_string(),
|
||||||
|
valid_fields: sortable_fields,
|
||||||
|
})?
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user