Skip to content

Commit

Permalink
Add date_range agg w/ filter query rest test
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <[email protected]>
  • Loading branch information
finnegancarroll committed Aug 12, 2024
1 parent 962d0dc commit 726b466
Showing 1 changed file with 38 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -675,22 +675,22 @@ setup:
- match: { aggregations.my_range.buckets.3.doc_count: 2 }

---
"Range query and aggregation test":
"Filter query w/ aggregation test":
- do:
bulk:
refresh: true
index: range-agg-w-query
body:
- '{"index": {}}'
- '{"routing": "route1", "v": -10}'
- '{"routing": "route1", "v": -10, "date": "2024-10-29"}'
- '{"index": {}}'
- '{"routing": "route1", "v": -5}'
- '{"routing": "route1", "v": -5, "date": "2024-10-30"}'
- '{"index": {}}'
- '{"routing": "route1", "v": 10}'
- '{"routing": "route1", "v": 10, "date": "2024-10-31"}'
- '{"index": {}}'
- '{"routing": "route2", "v": 15}'
- '{"routing": "route2", "v": 15, "date": "2024-11-01"}'
- '{"index": {}}'
- '{"routing": "route2", "v": 20}'
- '{"routing": "route2", "v": 20, "date": "2024-11-02"}'

- do:
search:
Expand All @@ -705,7 +705,7 @@ setup:
routing:
- "route1"
aggregations:
aggregationName:
NegPosAgg:
range:
field: v
keyed: true
Expand All @@ -717,5 +717,34 @@ setup:
_source: false

- match: { hits.total.value: 3 }
- match: { aggregations.aggregationName.buckets.0.doc_count: 2 }
- match: { aggregations.aggregationName.buckets.1.doc_count: 1 }
- match: { aggregations.NegPosAgg.buckets.0.doc_count: 2 }
- match: { aggregations.NegPosAgg.buckets.1.doc_count: 1 }

- do:
search:
index: range-agg-w-query
body:
query:
bool:
must:
match_all: {}
filter:
- terms:
routing:
- "route1"
aggregations:
HalloweenAgg:
date_range:
field: date
format: "yyyy-MM-dd"
keyed: true
ranges:
- to: "2024-11-01"
key: "to-october"
- from: "2024-11-01"
key: "from-september"
_source: false

- match: { hits.total.value: 3 }
- match: { aggregations.HalloweenAgg.buckets.to-october.doc_count: 3 }
- match: { aggregations.HalloweenAgg.buckets.from-september.doc_count: 0 }

0 comments on commit 726b466

Please sign in to comment.