Skip to content

Commit b9017da

Browse files
authored
Fix hard_bounds interval handling (#62129)
The hard bounds were incorrectly scaled for intervals, which was causing incorrect buckets to show up or no buckets at all for interval other than 1. Closes #62126
1 parent 9c2b214 commit b9017da

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/HistogramIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ public void testHardBounds() throws Exception {
12371237
assertEquals(-0.6, (double) buckets.get(0).getKey(), 0.01d);
12381238

12391239
r = client().prepareSearch("test")
1240-
.addAggregation(histogram("histo").field("d").interval(0.1).hardBounds(new DoubleBounds(0.0, 3.0)))
1240+
.addAggregation(histogram("histo").field("d").interval(0.1).hardBounds(new DoubleBounds(0.0, 0.3)))
12411241
.get();
12421242
assertSearchResponse(r);
12431243

server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/NumericHistogramAggregator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void collect(int doc, long owningBucketOrd) throws IOException {
110110
if (key == previousKey) {
111111
continue;
112112
}
113-
if (hardBounds == null || hardBounds.contain(key)) {
113+
if (hardBounds == null || hardBounds.contain(key * interval)) {
114114
long bucketOrd = bucketOrds.add(owningBucketOrd, Double.doubleToLongBits(key));
115115
if (bucketOrd < 0) { // already seen
116116
bucketOrd = -1 - bucketOrd;

0 commit comments

Comments
 (0)