diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-10-18 13:15:12 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-10-18 13:15:12 -0700 |
commit | a7ca6a594a3e52909a6bf0b51fb8a5bb59368cb6 (patch) | |
tree | 1018dbebc6f35bbb8c18e4a3ca7e74324faab576 | |
parent | bd2809dbde925eb3c12640a7fa4cbe38a62151d0 (diff) | |
download | es-public-proxy-a7ca6a594a3e52909a6bf0b51fb8a5bb59368cb6.tar.gz es-public-proxy-a7ca6a594a3e52909a6bf0b51fb8a5bb59368cb6.zip |
schema: filters can be single or array
-rw-r--r-- | src/parse.rs | 18 |
1 files 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 @@ -233,6 +233,14 @@ pub struct ApiQuery { #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[serde(untagged)] +pub enum ApiQueryOrArray { + Single(ApiQuery), + Array(Vec<ApiQuery>), +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(deny_unknown_fields)] pub struct ApiHighlight { // TODO: fields could also be an array of strings? fields: HashMap<String, HighlightField>, @@ -499,13 +507,13 @@ pub struct QueryField { #[serde(deny_unknown_fields)] pub struct BoolQuery { #[serde(skip_serializing_if = "Option::is_none")] - must: Option<Box<ApiQuery>>, + must: Option<Box<ApiQueryOrArray>>, #[serde(skip_serializing_if = "Option::is_none")] - filter: Option<Box<ApiQuery>>, + filter: Option<Box<ApiQueryOrArray>>, #[serde(skip_serializing_if = "Option::is_none")] - should: Option<Box<ApiQuery>>, + should: Option<Box<ApiQueryOrArray>>, #[serde(skip_serializing_if = "Option::is_none")] - must_not: Option<Box<ApiQuery>>, + must_not: Option<Box<ApiQueryOrArray>>, #[serde(skip_serializing_if = "Option::is_none")] minimum_should_match: Option<StringOrNum>, #[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<ApiQuery>, + filter: Box<ApiQueryOrArray>, #[serde(skip_serializing_if = "Option::is_none")] boost: Option<Num>, } |