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:
Sandeep Kumar
2024-06-19 00:28:19 +05:30
committed by GitHub
parent 776ddb8c1a
commit ae1edb061d
4 changed files with 143 additions and 35 deletions

View File

@ -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,
}