From 9fc7c2e3fb6c33d7adb0f3dd9812f4c4cca18627 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Tue, 16 Jul 2024 10:02:01 -0700 Subject: [PATCH] Add range sub agg yaml rest tests Signed-off-by: Finn Carroll --- .../410_date_histo_sub_aggs.yml | 36 ++++++++- .../search.aggregation/420_range_sub_aggs.yml | 78 +++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/420_range_sub_aggs.yml diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/410_date_histo_sub_aggs.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/410_date_histo_sub_aggs.yml index 8e003a313cefa..d8c70722e1788 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/410_date_histo_sub_aggs.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/410_date_histo_sub_aggs.yml @@ -2,7 +2,7 @@ setup: - do: indices.create: - index: test_date_hist_range_sub_agg + index: test_date_hist_sub_aggs body: settings: number_of_shards: 1 @@ -76,3 +76,37 @@ setup: - match: { aggregations.histo.buckets.0.my_range.buckets.0.doc_count: 1 } - match: { aggregations.histo.buckets.7.my_range.buckets.2.doc_count: 2 } - match: { aggregations.histo.buckets.7.my_range.buckets.1.doc_count: 1 } + +--- +"auto_date_histogram with range sub aggregation": + - do: + search: + body: + size: 0 + aggs: + histo: + auto_date_histogram: + field: date + buckets: 3 + aggs: + my_range: + range: + field: v + ranges: + - to: 10 + - from: 10 + to: 20 + - from: 20 + to: 30 + - from: 30 + to: 40 + + - match: { hits.total.value: 9 } + - length: { aggregations.histo.buckets: 2 } + + - match: { aggregations.histo.buckets.0.doc_count: 4 } + - match: { aggregations.histo.buckets.1.doc_count: 5 } +# +# - match: { aggregations.histo.buckets.0.my_range.buckets.0.doc_count: 1 } +# - match: { aggregations.histo.buckets.7.my_range.buckets.2.doc_count: 2 } +# - match: { aggregations.histo.buckets.7.my_range.buckets.1.doc_count: 1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/420_range_sub_aggs.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/420_range_sub_aggs.yml new file mode 100644 index 0000000000000..0138ae9f036fe --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/420_range_sub_aggs.yml @@ -0,0 +1,78 @@ +--- +setup: + - do: + indices.create: + index: test_range_sub_aggs + body: + settings: + number_of_shards: 1 + number_of_replicas: 0 + mappings: + properties: + date: + type: date + - do: + bulk: + refresh: true + index: test + body: + - '{"index": {}}' + - '{"date": "2020-03-01", "v": 1}' + - '{"index": {}}' + - '{"date": "2020-03-01", "v": 11}' + - '{"index": {}}' + - '{"date": "2020-03-02", "v": 12}' + - '{"index": {}}' + - '{"date": "2020-03-02", "v": 22}' + - '{"index": {}}' + - '{"date": "2020-03-08", "v": 13}' + - '{"index": {}}' + - '{"date": "2020-03-08", "v": 28}' + - '{"index": {}}' + - '{"date": "2020-03-08", "v": 28}' + - '{"index": {}}' + - '{"date": "2020-03-08", "v": 39}' + - '{"index": {}}' + - '{"date": "2020-03-09", "v": 4}' + +--- +"date_histogram with range sub aggregation": + - do: + search: + body: + size: 0 + aggs: + my_range: + range: + field: v + ranges: + - to: 10 + - from: 10 + to: 20 + - from: 20 + to: 30 + - from: 30 + to: 40 + aggs: + histo: + date_histogram: + field: date + calendar_interval: day + +# - match: { hits.total.value: 9 } +# - length: { aggregations.histo.buckets: 9 } +# +# - match: { aggregations.histo.buckets.0.key_as_string: "2020-03-01T00:00:00.000Z" } +# - match: { aggregations.histo.buckets.1.key_as_string: "2020-03-02T00:00:00.000Z" } +# - match: { aggregations.histo.buckets.7.key_as_string: "2020-03-08T00:00:00.000Z" } +# - match: { aggregations.histo.buckets.8.key_as_string: "2020-03-09T00:00:00.000Z" } +# +# - match: { aggregations.histo.buckets.0.doc_count: 2 } +# - match: { aggregations.histo.buckets.1.doc_count: 2 } +# - match: { aggregations.histo.buckets.2.doc_count: 0 } +# - match: { aggregations.histo.buckets.7.doc_count: 4 } +# - match: { aggregations.histo.buckets.8.doc_count: 1 } +# +# - match: { aggregations.histo.buckets.0.my_range.buckets.0.doc_count: 1 } +# - match: { aggregations.histo.buckets.7.my_range.buckets.2.doc_count: 2 } +# - match: { aggregations.histo.buckets.7.my_range.buckets.1.doc_count: 1 }