mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-10 06:58:56 +01:00
federated queries: adjust error message
This commit is contained in:
parent
6732dd95d7
commit
dc8a662209
@ -32,9 +32,9 @@ pub enum MeilisearchHttpError {
|
|||||||
FederationOptionsInNonFederatedRequest(usize),
|
FederationOptionsInNonFederatedRequest(usize),
|
||||||
#[error("Inside `.queries[{0}]`: Using pagination options is not allowed in federated queries.\n - Hint: remove `{1}` from query #{0} or remove `federation` from the request\n - Hint: pass `federation.limit` and `federation.offset` for pagination in federated search")]
|
#[error("Inside `.queries[{0}]`: Using pagination options is not allowed in federated queries.\n - Hint: remove `{1}` from query #{0} or remove `federation` from the request\n - Hint: pass `federation.limit` and `federation.offset` for pagination in federated search")]
|
||||||
PaginationInFederatedQuery(usize, &'static str),
|
PaginationInFederatedQuery(usize, &'static str),
|
||||||
#[error("Inside `.queries[{0}]`: Using facet options is not allowed in federated queries.\n Hint: remove `facets` from query #{0} or remove `federation` from the request")]
|
#[error("Inside `.queries[{0}]`: Using facet options is not allowed in federated queries.\n - Hint: remove `facets` from query #{0} or remove `federation` from the request\n - Hint: pass `federation.facetsByIndex.{1}: {2:?}` for facets in federated search")]
|
||||||
FacetsInFederatedQuery(usize),
|
FacetsInFederatedQuery(usize, String, Vec<String>),
|
||||||
#[error("Inconsistent order for values in facet `{facet}`: index `{previous_uid}` orders {previous_facet_order}, but index `{current_uid}` orders {index_facet_order}.\n Hint: Remove `federation.mergeFacets` or set `federation.mergeFacets.sortFacetValuesBy` to the desired order.")]
|
#[error("Inconsistent order for values in facet `{facet}`: index `{previous_uid}` orders {previous_facet_order}, but index `{current_uid}` orders {index_facet_order}.\n - Hint: Remove `federation.mergeFacets` or set `federation.mergeFacets.sortFacetValuesBy` to the desired order.")]
|
||||||
InconsistentFacetOrder {
|
InconsistentFacetOrder {
|
||||||
facet: String,
|
facet: String,
|
||||||
previous_facet_order: OrderBy,
|
previous_facet_order: OrderBy,
|
||||||
@ -107,7 +107,7 @@ impl ErrorCode for MeilisearchHttpError {
|
|||||||
MeilisearchHttpError::PaginationInFederatedQuery(_, _) => {
|
MeilisearchHttpError::PaginationInFederatedQuery(_, _) => {
|
||||||
Code::InvalidMultiSearchQueryPagination
|
Code::InvalidMultiSearchQueryPagination
|
||||||
}
|
}
|
||||||
MeilisearchHttpError::FacetsInFederatedQuery(_) => Code::InvalidMultiSearchQueryFacets,
|
MeilisearchHttpError::FacetsInFederatedQuery(..) => Code::InvalidMultiSearchQueryFacets,
|
||||||
MeilisearchHttpError::InconsistentFacetOrder { .. } => {
|
MeilisearchHttpError::InconsistentFacetOrder { .. } => {
|
||||||
Code::InvalidMultiSearchFacetOrder
|
Code::InvalidMultiSearchFacetOrder
|
||||||
}
|
}
|
||||||
|
@ -513,8 +513,14 @@ pub fn perform_federated_search(
|
|||||||
.into());
|
.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if federated_query.has_facets() {
|
if let Some(facets) = federated_query.has_facets() {
|
||||||
return Err(MeilisearchHttpError::FacetsInFederatedQuery(query_index).into());
|
let facets = facets.to_owned();
|
||||||
|
return Err(MeilisearchHttpError::FacetsInFederatedQuery(
|
||||||
|
query_index,
|
||||||
|
federated_query.index_uid.into_inner(),
|
||||||
|
facets,
|
||||||
|
)
|
||||||
|
.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let (index_uid, query, federation_options) = federated_query.into_index_query_federation();
|
let (index_uid, query, federation_options) = federated_query.into_index_query_federation();
|
||||||
|
@ -455,9 +455,8 @@ impl SearchQueryWithIndex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_facets(&self) -> bool {
|
pub fn has_facets(&self) -> Option<&[String]> {
|
||||||
let Some(facets) = &self.facets else { return false };
|
self.facets.as_deref().filter(|v| !v.is_empty())
|
||||||
!facets.is_empty()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_index_query_federation(self) -> (IndexUid, SearchQuery, Option<FederationOptions>) {
|
pub fn into_index_query_federation(self) -> (IndexUid, SearchQuery, Option<FederationOptions>) {
|
||||||
|
Loading…
Reference in New Issue
Block a user