mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 12:15:40 +08:00
fix(opensearch): handle index not present errors in search api (#4965)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: ivor-juspay <138492857+ivor-juspay@users.noreply.github.com>
This commit is contained in:
@ -48,19 +48,40 @@ pub struct GetSearchResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct OpenMsearchOutput<T> {
|
||||
pub responses: Vec<OpensearchOutput<T>>,
|
||||
pub struct OpenMsearchOutput {
|
||||
pub responses: Vec<OpensearchOutput>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct OpensearchOutput<T> {
|
||||
pub hits: OpensearchResults<T>,
|
||||
#[serde(untagged)]
|
||||
pub enum OpensearchOutput {
|
||||
Success(OpensearchSuccess),
|
||||
Error(OpensearchError),
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct OpensearchResults<T> {
|
||||
pub struct OpensearchError {
|
||||
pub error: OpensearchErrorDetails,
|
||||
pub status: u16,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct OpensearchErrorDetails {
|
||||
#[serde(rename = "type")]
|
||||
pub error_type: String,
|
||||
pub reason: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct OpensearchSuccess {
|
||||
pub status: u16,
|
||||
pub hits: OpensearchHits,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct OpensearchHits {
|
||||
pub total: OpensearchResultsTotal,
|
||||
pub hits: Vec<OpensearchHits<T>>,
|
||||
pub hits: Vec<OpensearchHit>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
@ -69,6 +90,7 @@ pub struct OpensearchResultsTotal {
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct OpensearchHits<T> {
|
||||
pub _source: T,
|
||||
pub struct OpensearchHit {
|
||||
#[serde(rename = "_source")]
|
||||
pub source: Value,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user