Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ setup:
half_float:
type: half_float

- do:
indices.create:
index: date_range_test
body:
settings:
number_of_replicas: 0
mappings:
properties:
date:
type: date
format: strict_date_time||strict_date

- do:
cluster.health:
wait_for_status: yellow
Expand All @@ -35,13 +47,30 @@ setup:
- {"index": {}}
- {}

- do:
bulk:
index: date_range_test
refresh: true
body:
- { "index": { } }
- { "date": "2021-05-01T07:10:00Z" }
- { "index": { } }
- { "date": "2021-05-02T08:34:00Z" }
- { "index": { } }
- { "date": "2021-05-03T08:36:00Z" }
- { "index": { } }
- { "date": "2021-05-04T09:05:00Z" }
- { "index": { } }
- { "date": "2021-05-06T09:22:00Z" }

---
"Float Endpoint Exclusive":
- skip:
version: " - 7.15.99"
reason: Bug fixed in 7.16.0
- do:
search:
index: test
body:
size: 0
aggs:
Expand Down Expand Up @@ -70,6 +99,7 @@ setup:
reason: Bug fixed in 7.16.0
- do:
search:
index: test
body:
size: 0
aggs:
Expand Down Expand Up @@ -98,6 +128,7 @@ setup:
reason: Bug fixed in 8.1.0 and backported to 7.17.0
- do:
search:
index: test
body:
size: 0
aggs:
Expand Down Expand Up @@ -136,6 +167,7 @@ setup:
reason: Bug fixed in 8.1.0 and backported to 7.17.0
- do:
search:
index: test
body:
size: 0
aggs:
Expand Down Expand Up @@ -171,6 +203,7 @@ setup:
"Double range no decimal":
- do:
search:
index: test
body:
size: 0
aggs:
Expand Down Expand Up @@ -206,6 +239,7 @@ setup:
"Double range with missing value":
- do:
search:
index: test
body:
size: 0
aggs:
Expand Down Expand Up @@ -242,6 +276,7 @@ setup:
"Null to and from":
- do:
search:
index: test
body:
size: 0
aggs:
Expand Down Expand Up @@ -279,6 +314,7 @@ setup:
"Range agg on long field":
- do:
search:
index: test
body:
size: 0
aggs:
Expand Down Expand Up @@ -314,6 +350,7 @@ setup:
"Double range default keyed response":
- do:
search:
index: test
body:
size: 0
aggs:
Expand Down Expand Up @@ -345,3 +382,30 @@ setup:
- match: { aggregations.double_range.buckets.last.from: 150.0 }
- is_false: aggregations.double_range.buckets.last.to
- match: { aggregations.double_range.buckets.last.doc_count: 0 }

---
"Range aggregation on date field":
- skip:
version: " - 8.0.99"
reason: Fixed in 8.1.0

- do:
search:
index: date_range_test
body:
size: 0
aggs:
date_range:
range:
field: date
ranges:
{ from: 2021-05-01T00:00:00Z, to: 2021-05-05T00:00:00Z }

- match: { hits.total.value: 5 }
- length: { aggregations.date_range.buckets: 1 }
- match: { aggregations.date_range.buckets.0.doc_count: 4 }
- match: { aggregations.date_range.buckets.0.key: "2021-05-01T00:00:00.000Z-2021-05-05T00:00:00.000Z" }
- match: { aggregations.date_range.buckets.0.from: 1619827200000 }
- match: { aggregations.date_range.buckets.0.from_as_string: "2021-05-01T00:00:00.000Z" }
- match: { aggregations.date_range.buckets.0.to: 1620172800000 }
- match: { aggregations.date_range.buckets.0.to_as_string: "2021-05-05T00:00:00.000Z" }
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ protected RangeAggregatorFactory innerBuild(
if (range.toAsStr != null) {
to = parser.parseDouble(range.toAsStr, false, context::nowInMillis);
}
String key = range.key != null ? range.key : generateKey(range.originalFrom, range.originalTo, config.format());
return new Range(key, from, range.from, range.fromAsStr, to, range.to, range.toAsStr);
double originalFrom = range.fromAsStr != null ? from : range.from;
double originalTo = range.toAsStr != null ? to : range.to;
String key = range.key != null ? range.key : generateKey(originalFrom, originalTo, config.format());
return new Range(key, from, originalFrom, range.fromAsStr, to, originalTo, range.toAsStr);
});
if (ranges.length == 0) {
throw new IllegalArgumentException("No [ranges] specified for the [" + this.getName() + "] aggregation");
Expand Down