mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 21:07:58 +08:00
refactor(opensearch): Add Error Handling for Empty Query and Filters in Request (#5432)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -16,6 +16,17 @@ pub async fn msearch_results(
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
indexes: Vec<SearchIndex>,
|
||||
) -> CustomResult<Vec<GetSearchResponse>, OpenSearchError> {
|
||||
if req.query.trim().is_empty()
|
||||
&& req
|
||||
.filters
|
||||
.as_ref()
|
||||
.map_or(true, |filters| filters.is_all_none())
|
||||
{
|
||||
return Err(OpenSearchError::BadRequestError(
|
||||
"Both query and filters are empty".to_string(),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
let mut query_builder =
|
||||
OpenSearchQueryBuilder::new(OpenSearchQuery::Msearch(indexes.clone()), req.query);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user