Skip to content

Commit

Permalink
Add range sub agg yaml rest tests
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <[email protected]>
  • Loading branch information
finnegancarroll committed Jul 16, 2024
1 parent 6ef3703 commit 9fc7c2e
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Original file line number Diff line number Diff line change
@@ -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 }

0 comments on commit 9fc7c2e

Please sign in to comment.