mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-29 16:45:30 +08:00
fix the sort error messages
This commit is contained in:
parent
654f49ccec
commit
539a57026d
@ -83,7 +83,6 @@ impl ErrorCode for MilliError<'_> {
|
|||||||
UserError::AttributeLimitReached => Code::MaxFieldsLimitExceeded,
|
UserError::AttributeLimitReached => Code::MaxFieldsLimitExceeded,
|
||||||
UserError::InvalidFilter(_) => Code::Filter,
|
UserError::InvalidFilter(_) => Code::Filter,
|
||||||
UserError::InvalidFilterAttribute(_) => Code::Filter,
|
UserError::InvalidFilterAttribute(_) => Code::Filter,
|
||||||
UserError::InvalidSortName { .. } => Code::Sort,
|
|
||||||
UserError::MissingDocumentId { .. } => Code::MissingDocumentId,
|
UserError::MissingDocumentId { .. } => Code::MissingDocumentId,
|
||||||
UserError::MissingPrimaryKey => Code::MissingPrimaryKey,
|
UserError::MissingPrimaryKey => Code::MissingPrimaryKey,
|
||||||
UserError::PrimaryKeyCannotBeChanged => Code::PrimaryKeyAlreadyPresent,
|
UserError::PrimaryKeyCannotBeChanged => Code::PrimaryKeyAlreadyPresent,
|
||||||
@ -92,9 +91,9 @@ impl ErrorCode for MilliError<'_> {
|
|||||||
UserError::UnknownInternalDocumentId { .. } => Code::DocumentNotFound,
|
UserError::UnknownInternalDocumentId { .. } => Code::DocumentNotFound,
|
||||||
UserError::InvalidFacetsDistribution { .. } => Code::BadRequest,
|
UserError::InvalidFacetsDistribution { .. } => Code::BadRequest,
|
||||||
UserError::InvalidGeoField { .. } => Code::InvalidGeoField,
|
UserError::InvalidGeoField { .. } => Code::InvalidGeoField,
|
||||||
UserError::InvalidSortableAttribute { .. }
|
UserError::InvalidSortableAttribute { .. } => Code::Sort,
|
||||||
| UserError::InvalidReservedSortName { .. } => Code::Sort,
|
UserError::SortError(_) => Code::Sort,
|
||||||
UserError::CriterionError(_) => Code::BadRequest,
|
UserError::CriterionError(_) => Code::InvalidRankingRule,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ impl ErrorCode for MilliError<'_> {
|
|||||||
UserError::AttributeLimitReached => Code::MaxFieldsLimitExceeded,
|
UserError::AttributeLimitReached => Code::MaxFieldsLimitExceeded,
|
||||||
UserError::InvalidFilter(_) => Code::Filter,
|
UserError::InvalidFilter(_) => Code::Filter,
|
||||||
UserError::InvalidFilterAttribute(_) => Code::Filter,
|
UserError::InvalidFilterAttribute(_) => Code::Filter,
|
||||||
UserError::InvalidSortName { .. } => Code::Sort,
|
|
||||||
UserError::MissingDocumentId { .. } => Code::MissingDocumentId,
|
UserError::MissingDocumentId { .. } => Code::MissingDocumentId,
|
||||||
UserError::MissingPrimaryKey => Code::MissingPrimaryKey,
|
UserError::MissingPrimaryKey => Code::MissingPrimaryKey,
|
||||||
UserError::PrimaryKeyCannotBeChanged => Code::PrimaryKeyAlreadyPresent,
|
UserError::PrimaryKeyCannotBeChanged => Code::PrimaryKeyAlreadyPresent,
|
||||||
@ -52,10 +51,10 @@ impl ErrorCode for MilliError<'_> {
|
|||||||
UserError::SortRankingRuleMissing => Code::Sort,
|
UserError::SortRankingRuleMissing => Code::Sort,
|
||||||
UserError::UnknownInternalDocumentId { .. } => Code::DocumentNotFound,
|
UserError::UnknownInternalDocumentId { .. } => Code::DocumentNotFound,
|
||||||
UserError::InvalidFacetsDistribution { .. } => Code::BadRequest,
|
UserError::InvalidFacetsDistribution { .. } => Code::BadRequest,
|
||||||
UserError::InvalidSortableAttribute { .. }
|
UserError::InvalidSortableAttribute { .. } => Code::Sort,
|
||||||
| UserError::InvalidReservedSortName { .. } => Code::Sort,
|
|
||||||
UserError::CriterionError(_) => Code::InvalidRankingRule,
|
UserError::CriterionError(_) => Code::InvalidRankingRule,
|
||||||
UserError::InvalidGeoField { .. } => Code::InvalidGeoField,
|
UserError::InvalidGeoField { .. } => Code::InvalidGeoField,
|
||||||
|
UserError::SortError(_) => Code::Sort,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@ use heed::RoTxn;
|
|||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use meilisearch_tokenizer::{Analyzer, AnalyzerConfig, Token};
|
use meilisearch_tokenizer::{Analyzer, AnalyzerConfig, Token};
|
||||||
use milli::{
|
use milli::{
|
||||||
AscDesc, AscDescError, FieldId, FieldsIdsMap, FilterCondition, MatchingWords, UserError,
|
AscDesc, AscDescError, FieldId, FieldsIdsMap, FilterCondition, MatchingWords, SortError,
|
||||||
|
UserError,
|
||||||
};
|
};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -113,15 +114,8 @@ impl Index {
|
|||||||
if let Some(ref sort) = query.sort {
|
if let Some(ref sort) = query.sort {
|
||||||
let sort = match sort.iter().map(|s| AscDesc::from_str(s)).collect() {
|
let sort = match sort.iter().map(|s| AscDesc::from_str(s)).collect() {
|
||||||
Ok(sorts) => sorts,
|
Ok(sorts) => sorts,
|
||||||
Err(AscDescError::InvalidSyntax { name }) => {
|
Err(asc_desc_error) => {
|
||||||
return Err(IndexError::Milli(
|
return Err(IndexError::Milli(SortError::from(asc_desc_error).into()))
|
||||||
UserError::InvalidSortName { name }.into(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
Err(AscDescError::ReservedKeyword { name }) => {
|
|
||||||
return Err(IndexError::Milli(
|
|
||||||
UserError::InvalidReservedSortName { name }.into(),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user