From a7ca6a594a3e52909a6bf0b51fb8a5bb59368cb6 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 18 Oct 2020 13:15:12 -0700 Subject: schema: filters can be single or array --- src/parse.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/parse.rs b/src/parse.rs index c2cb356..8656daa 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -231,6 +231,14 @@ pub struct ApiQuery { rescore_query_weight: Option, } +#[derive(Serialize, Deserialize, Debug)] +#[serde(deny_unknown_fields)] +#[serde(untagged)] +pub enum ApiQueryOrArray { + Single(ApiQuery), + Array(Vec), +} + #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct ApiHighlight { @@ -499,13 +507,13 @@ pub struct QueryField { #[serde(deny_unknown_fields)] pub struct BoolQuery { #[serde(skip_serializing_if = "Option::is_none")] - must: Option>, + must: Option>, #[serde(skip_serializing_if = "Option::is_none")] - filter: Option>, + filter: Option>, #[serde(skip_serializing_if = "Option::is_none")] - should: Option>, + should: Option>, #[serde(skip_serializing_if = "Option::is_none")] - must_not: Option>, + must_not: Option>, #[serde(skip_serializing_if = "Option::is_none")] minimum_should_match: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -536,7 +544,7 @@ pub struct BoostingQuery { #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct ConstantScoreQuery { - filter: Box, + filter: Box, #[serde(skip_serializing_if = "Option::is_none")] boost: Option, } -- cgit v1.2.3