diff options
-rw-r--r-- | src/parse.rs | 18 | ||||
-rw-r--r-- | tests/files/search/GET_search_agg_filters.txt | 14 | ||||
-rw-r--r-- | tests/files/search/GET_search_agg_filters_anon.txt | 14 | ||||
-rw-r--r-- | tests/files/search/GET_search_agg_filters_other.txt | 15 |
4 files changed, 61 insertions, 0 deletions
diff --git a/src/parse.rs b/src/parse.rs index 8656daa..07c55a0 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -241,6 +241,14 @@ pub enum ApiQueryOrArray { #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[serde(untagged)] +pub enum ApiQueryNamedOrArray { + Named(HashMap<String, 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>, @@ -644,6 +652,8 @@ pub struct ApiAggregation { #[serde(skip_serializing_if = "Option::is_none")] filter: Option<ApiQuery>, #[serde(skip_serializing_if = "Option::is_none")] + filters: Option<FiltersAggregation>, + #[serde(skip_serializing_if = "Option::is_none")] histogram: Option<SimpleAggregation>, #[serde(skip_serializing_if = "Option::is_none")] terms: Option<TermsAggregation>, @@ -715,6 +725,14 @@ pub struct DateHistogramAggregation { #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] +pub struct FiltersAggregation { + #[serde(skip_serializing_if = "Option::is_none")] + other_bucket_key: Option<String>, + filters: ApiQueryNamedOrArray, +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(deny_unknown_fields)] pub struct TermsAggregation { field: String, #[serde(skip_serializing_if = "Option::is_none")] diff --git a/tests/files/search/GET_search_agg_filters.txt b/tests/files/search/GET_search_agg_filters.txt new file mode 100644 index 0000000..74b2976 --- /dev/null +++ b/tests/files/search/GET_search_agg_filters.txt @@ -0,0 +1,14 @@ +GET /logs/_search +{ + "size": 0, + "aggs" : { + "messages" : { + "filters" : { + "filters" : { + "errors" : { "match" : { "body" : "error" }}, + "warnings" : { "match" : { "body" : "warning" }} + } + } + } + } +} diff --git a/tests/files/search/GET_search_agg_filters_anon.txt b/tests/files/search/GET_search_agg_filters_anon.txt new file mode 100644 index 0000000..baa550d --- /dev/null +++ b/tests/files/search/GET_search_agg_filters_anon.txt @@ -0,0 +1,14 @@ +GET /logs/_search +{ + "size": 0, + "aggs" : { + "messages" : { + "filters" : { + "filters" : [ + { "match" : { "body" : "error" }}, + { "match" : { "body" : "warning" }} + ] + } + } + } +} diff --git a/tests/files/search/GET_search_agg_filters_other.txt b/tests/files/search/GET_search_agg_filters_other.txt new file mode 100644 index 0000000..dd54e48 --- /dev/null +++ b/tests/files/search/GET_search_agg_filters_other.txt @@ -0,0 +1,15 @@ +GET /logs/_search +{ + "size": 0, + "aggs" : { + "messages" : { + "filters" : { + "other_bucket_key": "other_messages", + "filters" : { + "errors" : { "match" : { "body" : "error" }}, + "warnings" : { "match" : { "body" : "warning" }} + } + } + } + } +} |