diff options
Diffstat (limited to 'src/parse.rs')
-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>, } |