aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/parse.rs26
-rw-r--r--tests/files/search/GET_search_agg_composite_date_histogram.txt13
-rw-r--r--tests/files/search/GET_search_agg_composite_early.txt15
-rw-r--r--tests/files/search/GET_search_agg_composite_histogram.txt13
-rw-r--r--tests/files/search/GET_search_agg_composite_missing.txt13
-rw-r--r--tests/files/search/GET_search_agg_composite_mixed.txt15
-rw-r--r--tests/files/search/GET_search_agg_composite_order.txt14
-rw-r--r--tests/files/search/GET_search_agg_composite_paginate.txt16
-rw-r--r--tests/files/search/GET_search_agg_composite_sub.txt19
-rw-r--r--tests/files/search/GET_search_agg_composite_terms.txt13
-rw-r--r--tests/files/search/GET_search_agg_date_histogram_offset.txt12
-rw-r--r--tests/files/search/GET_search_agg_date_histogram_timezone.txt12
-rw-r--r--tests/files/search/POST_search_agg_date_histogram.txt11
-rw-r--r--tests/files/search/POST_search_agg_date_histogram_fixed_interval.txt11
-rw-r--r--tests/files/search/POST_search_agg_date_histogram_format.txt12
-rw-r--r--tests/files/search/POST_search_agg_date_histogram_keyed.txt13
-rw-r--r--tests/files/search/POST_search_agg_date_histogram_missing.txt12
-rw-r--r--tests/files/search/POST_search_agg_filter_simple.txt (renamed from tests/files/search/GET_search_agg_filter_simple.txt)0
-rw-r--r--tests/files/search/POST_search_agg_histogram.txt (renamed from tests/files/search/GET_search_agg_histogram.txt)0
-rw-r--r--tests/files/search/POST_search_agg_max.txt (renamed from tests/files/search/GET_search_agg_max.txt)0
20 files changed, 238 insertions, 2 deletions
diff --git a/src/parse.rs b/src/parse.rs
index 07c55a0..10216f7 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -141,6 +141,8 @@ pub struct SearchBody {
pub terminate_after: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout: Option<String>, // string is "time units"
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub track_total_hits: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug)]
@@ -654,8 +656,12 @@ pub struct ApiAggregation {
#[serde(skip_serializing_if = "Option::is_none")]
filters: Option<FiltersAggregation>,
#[serde(skip_serializing_if = "Option::is_none")]
+ composite: Option<CompositeAggregation>,
+ #[serde(skip_serializing_if = "Option::is_none")]
histogram: Option<SimpleAggregation>,
#[serde(skip_serializing_if = "Option::is_none")]
+ date_histogram: Option<DateHistogramAggregation>,
+ #[serde(skip_serializing_if = "Option::is_none")]
terms: Option<TermsAggregation>,
#[serde(skip_serializing_if = "Option::is_none")]
significant_terms: Option<SimpleAggregation>,
@@ -698,6 +704,8 @@ pub struct SimpleAggregation {
#[serde(skip_serializing_if = "Option::is_none")]
missing: Option<StringOrNum>,
#[serde(skip_serializing_if = "Option::is_none")]
+ missing_bucket: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
keyed: Option<bool>,
}
@@ -716,11 +724,23 @@ pub struct DateHistogramAggregation {
#[serde(skip_serializing_if = "Option::is_none")]
offset: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
- order: Option<HashMap<String, String>>,
+ order: Option<SortElement>,
#[serde(skip_serializing_if = "Option::is_none")]
keyed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
missing: Option<StringOrNum>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ missing_bucket: Option<bool>,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(deny_unknown_fields)]
+pub struct CompositeAggregation {
+ sources: Vec<HashMap<String,ApiAggregation>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ size: Option<u32>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ after: Option<HashMap<String, StringOrNum>>,
}
#[derive(Serialize, Deserialize, Debug)]
@@ -744,7 +764,7 @@ pub struct TermsAggregation {
#[serde(skip_serializing_if = "Option::is_none")]
show_term_doc_count_error: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
- order: Option<HashMap<String, String>>,
+ order: Option<SortElement>,
#[serde(skip_serializing_if = "Option::is_none")]
include: Option<StringOrArray>,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -753,4 +773,6 @@ pub struct TermsAggregation {
execution_hint: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
missing: Option<StringOrNum>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ missing_bucket: Option<bool>,
}
diff --git a/tests/files/search/GET_search_agg_composite_date_histogram.txt b/tests/files/search/GET_search_agg_composite_date_histogram.txt
new file mode 100644
index 0000000..4fb10ce
--- /dev/null
+++ b/tests/files/search/GET_search_agg_composite_date_histogram.txt
@@ -0,0 +1,13 @@
+GET /some-index/_search
+{
+ "size": 0,
+ "aggs": {
+ "my_buckets": {
+ "composite": {
+ "sources": [
+ { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d" } } }
+ ]
+ }
+ }
+ }
+}
diff --git a/tests/files/search/GET_search_agg_composite_early.txt b/tests/files/search/GET_search_agg_composite_early.txt
new file mode 100644
index 0000000..c0ab7cd
--- /dev/null
+++ b/tests/files/search/GET_search_agg_composite_early.txt
@@ -0,0 +1,15 @@
+GET /some-index/_search
+{
+ "size": 0,
+ "track_total_hits": false,
+ "aggs": {
+ "my_buckets": {
+ "composite": {
+ "sources": [
+ { "user_name": { "terms": { "field": "user_name" } } },
+ { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } }
+ ]
+ }
+ }
+ }
+}
diff --git a/tests/files/search/GET_search_agg_composite_histogram.txt b/tests/files/search/GET_search_agg_composite_histogram.txt
new file mode 100644
index 0000000..3bace14
--- /dev/null
+++ b/tests/files/search/GET_search_agg_composite_histogram.txt
@@ -0,0 +1,13 @@
+GET /some-index/_search
+{
+ "size": 0,
+ "aggs": {
+ "my_buckets": {
+ "composite": {
+ "sources": [
+ { "histo": { "histogram": { "field": "price", "interval": 5 } } }
+ ]
+ }
+ }
+ }
+}
diff --git a/tests/files/search/GET_search_agg_composite_missing.txt b/tests/files/search/GET_search_agg_composite_missing.txt
new file mode 100644
index 0000000..c46e190
--- /dev/null
+++ b/tests/files/search/GET_search_agg_composite_missing.txt
@@ -0,0 +1,13 @@
+GET /some-index/_search
+{
+ "size": 0,
+ "aggs": {
+ "my_buckets": {
+ "composite": {
+ "sources": [
+ { "product_name": { "terms": { "field": "product", "missing_bucket": true } } }
+ ]
+ }
+ }
+ }
+}
diff --git a/tests/files/search/GET_search_agg_composite_mixed.txt b/tests/files/search/GET_search_agg_composite_mixed.txt
new file mode 100644
index 0000000..4649d8c
--- /dev/null
+++ b/tests/files/search/GET_search_agg_composite_mixed.txt
@@ -0,0 +1,15 @@
+GET /some-index/_search
+{
+ "size": 0,
+ "aggs": {
+ "my_buckets": {
+ "composite": {
+ "sources": [
+ { "shop": { "terms": { "field": "shop" } } },
+ { "product": { "terms": { "field": "product" } } },
+ { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d" } } }
+ ]
+ }
+ }
+ }
+}
diff --git a/tests/files/search/GET_search_agg_composite_order.txt b/tests/files/search/GET_search_agg_composite_order.txt
new file mode 100644
index 0000000..20a42e1
--- /dev/null
+++ b/tests/files/search/GET_search_agg_composite_order.txt
@@ -0,0 +1,14 @@
+GET /some-index/_search
+{
+ "size": 0,
+ "aggs": {
+ "my_buckets": {
+ "composite": {
+ "sources": [
+ { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } },
+ { "product": { "terms": { "field": "product", "order": "asc" } } }
+ ]
+ }
+ }
+ }
+}
diff --git a/tests/files/search/GET_search_agg_composite_paginate.txt b/tests/files/search/GET_search_agg_composite_paginate.txt
new file mode 100644
index 0000000..53f3a5c
--- /dev/null
+++ b/tests/files/search/GET_search_agg_composite_paginate.txt
@@ -0,0 +1,16 @@
+GET /some-index/_search
+{
+ "size": 0,
+ "aggs": {
+ "my_buckets": {
+ "composite": {
+ "size": 2,
+ "sources": [
+ { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } },
+ { "product": { "terms": { "field": "product", "order": "asc" } } }
+ ],
+ "after": { "date": 1494288000000, "product": "mad max" }
+ }
+ }
+ }
+}
diff --git a/tests/files/search/GET_search_agg_composite_sub.txt b/tests/files/search/GET_search_agg_composite_sub.txt
new file mode 100644
index 0000000..757183f
--- /dev/null
+++ b/tests/files/search/GET_search_agg_composite_sub.txt
@@ -0,0 +1,19 @@
+GET /some-index/_search
+{
+ "size": 0,
+ "aggs": {
+ "my_buckets": {
+ "composite": {
+ "sources": [
+ { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } },
+ { "product": { "terms": { "field": "product" } } }
+ ]
+ },
+ "aggregations": {
+ "the_avg": {
+ "avg": { "field": "price" }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/files/search/GET_search_agg_composite_terms.txt b/tests/files/search/GET_search_agg_composite_terms.txt
new file mode 100644
index 0000000..403fc2c
--- /dev/null
+++ b/tests/files/search/GET_search_agg_composite_terms.txt
@@ -0,0 +1,13 @@
+GET /some-index/_search
+{
+ "size": 0,
+ "aggs": {
+ "my_buckets": {
+ "composite": {
+ "sources": [
+ { "product": { "terms": { "field": "product" } } }
+ ]
+ }
+ }
+ }
+}
diff --git a/tests/files/search/GET_search_agg_date_histogram_offset.txt b/tests/files/search/GET_search_agg_date_histogram_offset.txt
new file mode 100644
index 0000000..0a613de
--- /dev/null
+++ b/tests/files/search/GET_search_agg_date_histogram_offset.txt
@@ -0,0 +1,12 @@
+GET /my-index-000001/_search?size=0
+{
+ "aggs": {
+ "by_day": {
+ "date_histogram": {
+ "field": "date",
+ "calendar_interval": "day",
+ "offset": "+6h"
+ }
+ }
+ }
+}
diff --git a/tests/files/search/GET_search_agg_date_histogram_timezone.txt b/tests/files/search/GET_search_agg_date_histogram_timezone.txt
new file mode 100644
index 0000000..0bf992e
--- /dev/null
+++ b/tests/files/search/GET_search_agg_date_histogram_timezone.txt
@@ -0,0 +1,12 @@
+GET /my-index-000001/_search?size=0
+{
+ "aggs": {
+ "by_day": {
+ "date_histogram": {
+ "field": "date",
+ "calendar_interval": "day",
+ "time_zone": "-01:00"
+ }
+ }
+ }
+}
diff --git a/tests/files/search/POST_search_agg_date_histogram.txt b/tests/files/search/POST_search_agg_date_histogram.txt
new file mode 100644
index 0000000..731af13
--- /dev/null
+++ b/tests/files/search/POST_search_agg_date_histogram.txt
@@ -0,0 +1,11 @@
+POST /sales/_search?size=0
+{
+ "aggs": {
+ "sales_over_time": {
+ "date_histogram": {
+ "field": "date",
+ "calendar_interval": "month"
+ }
+ }
+ }
+}
diff --git a/tests/files/search/POST_search_agg_date_histogram_fixed_interval.txt b/tests/files/search/POST_search_agg_date_histogram_fixed_interval.txt
new file mode 100644
index 0000000..e98ad70
--- /dev/null
+++ b/tests/files/search/POST_search_agg_date_histogram_fixed_interval.txt
@@ -0,0 +1,11 @@
+POST /sales/_search?size=0
+{
+ "aggs": {
+ "sales_over_time": {
+ "date_histogram": {
+ "field": "date",
+ "fixed_interval": "30d"
+ }
+ }
+ }
+}
diff --git a/tests/files/search/POST_search_agg_date_histogram_format.txt b/tests/files/search/POST_search_agg_date_histogram_format.txt
new file mode 100644
index 0000000..1063343
--- /dev/null
+++ b/tests/files/search/POST_search_agg_date_histogram_format.txt
@@ -0,0 +1,12 @@
+POST /sales/_search?size=0
+{
+ "aggs": {
+ "sales_over_time": {
+ "date_histogram": {
+ "field": "date",
+ "calendar_interval": "1M",
+ "format": "yyyy-MM-dd"
+ }
+ }
+ }
+}
diff --git a/tests/files/search/POST_search_agg_date_histogram_keyed.txt b/tests/files/search/POST_search_agg_date_histogram_keyed.txt
new file mode 100644
index 0000000..7994b72
--- /dev/null
+++ b/tests/files/search/POST_search_agg_date_histogram_keyed.txt
@@ -0,0 +1,13 @@
+POST /sales/_search?size=0
+{
+ "aggs": {
+ "sales_over_time": {
+ "date_histogram": {
+ "field": "date",
+ "calendar_interval": "1M",
+ "format": "yyyy-MM-dd",
+ "keyed": true
+ }
+ }
+ }
+}
diff --git a/tests/files/search/POST_search_agg_date_histogram_missing.txt b/tests/files/search/POST_search_agg_date_histogram_missing.txt
new file mode 100644
index 0000000..3c9b95c
--- /dev/null
+++ b/tests/files/search/POST_search_agg_date_histogram_missing.txt
@@ -0,0 +1,12 @@
+POST /sales/_search?size=0
+{
+ "aggs": {
+ "sale_date": {
+ "date_histogram": {
+ "field": "date",
+ "calendar_interval": "year",
+ "missing": "2000/01/01"
+ }
+ }
+ }
+}
diff --git a/tests/files/search/GET_search_agg_filter_simple.txt b/tests/files/search/POST_search_agg_filter_simple.txt
index 71a9777..71a9777 100644
--- a/tests/files/search/GET_search_agg_filter_simple.txt
+++ b/tests/files/search/POST_search_agg_filter_simple.txt
diff --git a/tests/files/search/GET_search_agg_histogram.txt b/tests/files/search/POST_search_agg_histogram.txt
index 4689ad1..4689ad1 100644
--- a/tests/files/search/GET_search_agg_histogram.txt
+++ b/tests/files/search/POST_search_agg_histogram.txt
diff --git a/tests/files/search/GET_search_agg_max.txt b/tests/files/search/POST_search_agg_max.txt
index 1377afc..1377afc 100644
--- a/tests/files/search/GET_search_agg_max.txt
+++ b/tests/files/search/POST_search_agg_max.txt