mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 08:41:00 +00:00
Differentiate between document sort error and search sort error
This commit is contained in:
@ -483,7 +483,8 @@ impl ErrorCode for milli::Error {
|
|||||||
UserError::InvalidVectorsMapType { .. }
|
UserError::InvalidVectorsMapType { .. }
|
||||||
| UserError::InvalidVectorsEmbedderConf { .. } => Code::InvalidVectorsType,
|
| UserError::InvalidVectorsEmbedderConf { .. } => Code::InvalidVectorsType,
|
||||||
UserError::TooManyVectors(_, _) => Code::TooManyVectors,
|
UserError::TooManyVectors(_, _) => Code::TooManyVectors,
|
||||||
UserError::SortError(_) => Code::InvalidSearchSort,
|
UserError::SortError { search: true, .. } => Code::InvalidSearchSort,
|
||||||
|
UserError::SortError { search: false, .. } => Code::InvalidDocumentSort,
|
||||||
UserError::InvalidMinTypoWordLenSetting(_, _) => {
|
UserError::InvalidMinTypoWordLenSetting(_, _) => {
|
||||||
Code::InvalidSettingsTypoTolerance
|
Code::InvalidSettingsTypoTolerance
|
||||||
}
|
}
|
||||||
|
@ -663,7 +663,7 @@ fn documents_by_query(
|
|||||||
let sorts: Vec<_> = match sort.iter().map(|s| milli::AscDesc::from_str(s)).collect() {
|
let sorts: Vec<_> = match sort.iter().map(|s| milli::AscDesc::from_str(s)).collect() {
|
||||||
Ok(sorts) => sorts,
|
Ok(sorts) => sorts,
|
||||||
Err(asc_desc_error) => {
|
Err(asc_desc_error) => {
|
||||||
return Err(milli::Error::from(milli::SortError::from(asc_desc_error)).into())
|
return Err(milli::SortError::from(asc_desc_error).into_documents_error().into())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Some(sorts)
|
Some(sorts)
|
||||||
|
@ -745,10 +745,9 @@ impl SearchByIndex {
|
|||||||
match sort.iter().map(|s| milli::AscDesc::from_str(s)).collect() {
|
match sort.iter().map(|s| milli::AscDesc::from_str(s)).collect() {
|
||||||
Ok(sorts) => sorts,
|
Ok(sorts) => sorts,
|
||||||
Err(asc_desc_error) => {
|
Err(asc_desc_error) => {
|
||||||
return Err(milli::Error::from(milli::SortError::from(
|
return Err(milli::SortError::from(asc_desc_error)
|
||||||
asc_desc_error,
|
.into_search_error()
|
||||||
))
|
.into())
|
||||||
.into())
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Some(sorts)
|
Some(sorts)
|
||||||
|
@ -1060,7 +1060,7 @@ pub fn prepare_search<'t>(
|
|||||||
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(asc_desc_error) => {
|
Err(asc_desc_error) => {
|
||||||
return Err(milli::Error::from(SortError::from(asc_desc_error)).into())
|
return Err(SortError::from(asc_desc_error).into_search_error().into())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -168,6 +168,16 @@ pub enum SortError {
|
|||||||
ReservedNameForFilter { name: String },
|
ReservedNameForFilter { name: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SortError {
|
||||||
|
pub fn into_search_error(self) -> Error {
|
||||||
|
Error::UserError(UserError::SortError { error: self, search: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_documents_error(self) -> Error {
|
||||||
|
Error::UserError(UserError::SortError { error: self, search: false })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<AscDescError> for SortError {
|
impl From<AscDescError> for SortError {
|
||||||
fn from(error: AscDescError) -> Self {
|
fn from(error: AscDescError) -> Self {
|
||||||
match error {
|
match error {
|
||||||
@ -190,12 +200,6 @@ impl From<AscDescError> for SortError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SortError> for Error {
|
|
||||||
fn from(error: SortError) -> Self {
|
|
||||||
Self::UserError(UserError::SortError(error))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use big_s::S;
|
use big_s::S;
|
||||||
|
@ -272,8 +272,8 @@ and can not be more than 511 bytes.", .document_id.to_string()
|
|||||||
PrimaryKeyCannotBeChanged(String),
|
PrimaryKeyCannotBeChanged(String),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
SerdeJson(serde_json::Error),
|
SerdeJson(serde_json::Error),
|
||||||
#[error(transparent)]
|
#[error("{error}")]
|
||||||
SortError(#[from] SortError),
|
SortError { error: SortError, search: bool },
|
||||||
#[error("An unknown internal document id have been used: `{document_id}`.")]
|
#[error("An unknown internal document id have been used: `{document_id}`.")]
|
||||||
UnknownInternalDocumentId { document_id: DocumentId },
|
UnknownInternalDocumentId { document_id: DocumentId },
|
||||||
#[error("`minWordSizeForTypos` setting is invalid. `oneTypo` and `twoTypos` fields should be between `0` and `255`, and `twoTypos` should be greater or equals to `oneTypo` but found `oneTypo: {0}` and twoTypos: {1}`.")]
|
#[error("`minWordSizeForTypos` setting is invalid. `oneTypo` and `twoTypos` fields should be between `0` and `255`, and `twoTypos` should be greater or equals to `oneTypo` but found `oneTypo: {0}` and twoTypos: {1}`.")]
|
||||||
|
@ -411,7 +411,7 @@ pub fn recursive_facet_sort<'ctx>(
|
|||||||
// FIXME: Should this return an error if the field is not found?
|
// FIXME: Should this return an error if the field is not found?
|
||||||
}
|
}
|
||||||
|
|
||||||
let geo_candidates = if need_geo_candidates {
|
let geo_candidates = if need_geo_candidates {
|
||||||
index.geo_faceted_documents_ids(rtxn)?
|
index.geo_faceted_documents_ids(rtxn)?
|
||||||
} else {
|
} else {
|
||||||
RoaringBitmap::new()
|
RoaringBitmap::new()
|
||||||
|
Reference in New Issue
Block a user