From 8a4376fb2a3404ffaf58b6946f1086bdc793aea5 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 17 Dec 2020 13:08:39 -0800 Subject: add support for date_histogram and composite aggregations --- .../GET_search_agg_composite_date_histogram.txt | 13 +++++++++++++ tests/files/search/GET_search_agg_composite_early.txt | 15 +++++++++++++++ .../search/GET_search_agg_composite_histogram.txt | 13 +++++++++++++ .../files/search/GET_search_agg_composite_missing.txt | 13 +++++++++++++ tests/files/search/GET_search_agg_composite_mixed.txt | 15 +++++++++++++++ tests/files/search/GET_search_agg_composite_order.txt | 14 ++++++++++++++ .../search/GET_search_agg_composite_paginate.txt | 16 ++++++++++++++++ tests/files/search/GET_search_agg_composite_sub.txt | 19 +++++++++++++++++++ tests/files/search/GET_search_agg_composite_terms.txt | 13 +++++++++++++ .../search/GET_search_agg_date_histogram_offset.txt | 12 ++++++++++++ .../search/GET_search_agg_date_histogram_timezone.txt | 12 ++++++++++++ tests/files/search/GET_search_agg_filter_simple.txt | 11 ----------- tests/files/search/GET_search_agg_histogram.txt | 13 ------------- tests/files/search/GET_search_agg_max.txt | 11 ----------- tests/files/search/POST_search_agg_date_histogram.txt | 11 +++++++++++ .../POST_search_agg_date_histogram_fixed_interval.txt | 11 +++++++++++ .../search/POST_search_agg_date_histogram_format.txt | 12 ++++++++++++ .../search/POST_search_agg_date_histogram_keyed.txt | 13 +++++++++++++ .../search/POST_search_agg_date_histogram_missing.txt | 12 ++++++++++++ tests/files/search/POST_search_agg_filter_simple.txt | 11 +++++++++++ tests/files/search/POST_search_agg_histogram.txt | 13 +++++++++++++ tests/files/search/POST_search_agg_max.txt | 11 +++++++++++ 22 files changed, 249 insertions(+), 35 deletions(-) create mode 100644 tests/files/search/GET_search_agg_composite_date_histogram.txt create mode 100644 tests/files/search/GET_search_agg_composite_early.txt create mode 100644 tests/files/search/GET_search_agg_composite_histogram.txt create mode 100644 tests/files/search/GET_search_agg_composite_missing.txt create mode 100644 tests/files/search/GET_search_agg_composite_mixed.txt create mode 100644 tests/files/search/GET_search_agg_composite_order.txt create mode 100644 tests/files/search/GET_search_agg_composite_paginate.txt create mode 100644 tests/files/search/GET_search_agg_composite_sub.txt create mode 100644 tests/files/search/GET_search_agg_composite_terms.txt create mode 100644 tests/files/search/GET_search_agg_date_histogram_offset.txt create mode 100644 tests/files/search/GET_search_agg_date_histogram_timezone.txt delete mode 100644 tests/files/search/GET_search_agg_filter_simple.txt delete mode 100644 tests/files/search/GET_search_agg_histogram.txt delete mode 100644 tests/files/search/GET_search_agg_max.txt create mode 100644 tests/files/search/POST_search_agg_date_histogram.txt create mode 100644 tests/files/search/POST_search_agg_date_histogram_fixed_interval.txt create mode 100644 tests/files/search/POST_search_agg_date_histogram_format.txt create mode 100644 tests/files/search/POST_search_agg_date_histogram_keyed.txt create mode 100644 tests/files/search/POST_search_agg_date_histogram_missing.txt create mode 100644 tests/files/search/POST_search_agg_filter_simple.txt create mode 100644 tests/files/search/POST_search_agg_histogram.txt create mode 100644 tests/files/search/POST_search_agg_max.txt (limited to 'tests') 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/GET_search_agg_filter_simple.txt b/tests/files/search/GET_search_agg_filter_simple.txt deleted file mode 100644 index 71a9777..0000000 --- a/tests/files/search/GET_search_agg_filter_simple.txt +++ /dev/null @@ -1,11 +0,0 @@ -POST /sales/_search?size=0 -{ - "aggs": { - "t_shirts": { - "filter": { "term": { "type": "t-shirt" } }, - "aggs": { - "avg_price": { "avg": { "field": "price" } } - } - } - } -} diff --git a/tests/files/search/GET_search_agg_histogram.txt b/tests/files/search/GET_search_agg_histogram.txt deleted file mode 100644 index 4689ad1..0000000 --- a/tests/files/search/GET_search_agg_histogram.txt +++ /dev/null @@ -1,13 +0,0 @@ -POST /sales/_search?size=0 -{ - "aggs": { - "quantity": { - "histogram": { - "field": "quantity", - "interval": 10, - "keyed": true, - "missing": 0 - } - } - } -} diff --git a/tests/files/search/GET_search_agg_max.txt b/tests/files/search/GET_search_agg_max.txt deleted file mode 100644 index 1377afc..0000000 --- a/tests/files/search/GET_search_agg_max.txt +++ /dev/null @@ -1,11 +0,0 @@ -POST /sales/_search -{ - "aggs" : { - "grade_max" : { - "max" : { - "field" : "grade", - "missing": 10 - } - } - } -} 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/POST_search_agg_filter_simple.txt b/tests/files/search/POST_search_agg_filter_simple.txt new file mode 100644 index 0000000..71a9777 --- /dev/null +++ b/tests/files/search/POST_search_agg_filter_simple.txt @@ -0,0 +1,11 @@ +POST /sales/_search?size=0 +{ + "aggs": { + "t_shirts": { + "filter": { "term": { "type": "t-shirt" } }, + "aggs": { + "avg_price": { "avg": { "field": "price" } } + } + } + } +} diff --git a/tests/files/search/POST_search_agg_histogram.txt b/tests/files/search/POST_search_agg_histogram.txt new file mode 100644 index 0000000..4689ad1 --- /dev/null +++ b/tests/files/search/POST_search_agg_histogram.txt @@ -0,0 +1,13 @@ +POST /sales/_search?size=0 +{ + "aggs": { + "quantity": { + "histogram": { + "field": "quantity", + "interval": 10, + "keyed": true, + "missing": 0 + } + } + } +} diff --git a/tests/files/search/POST_search_agg_max.txt b/tests/files/search/POST_search_agg_max.txt new file mode 100644 index 0000000..1377afc --- /dev/null +++ b/tests/files/search/POST_search_agg_max.txt @@ -0,0 +1,11 @@ +POST /sales/_search +{ + "aggs" : { + "grade_max" : { + "max" : { + "field" : "grade", + "missing": 10 + } + } + } +} -- cgit v1.2.3