Fix hard_bounds interval handling (#62129) (#62188)

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
This commit is contained in:
Igor Motov 2020-09-09 15:42:12 -04:00 committed by GitHub
parent e80f68ed77
commit b6bff56a56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -1236,7 +1236,7 @@ public class HistogramIT extends ESIntegTestCase {
assertEquals(-0.6, (double) buckets.get(0).getKey(), 0.01d);
r = client().prepareSearch("test")
.addAggregation(histogram("histo").field("d").interval(0.1).hardBounds(new DoubleBounds(0.0, 3.0)))
.addAggregation(histogram("histo").field("d").interval(0.1).hardBounds(new DoubleBounds(0.0, 0.3)))
.get();
assertSearchResponse(r);

View File

@ -110,7 +110,7 @@ public class NumericHistogramAggregator extends AbstractHistogramAggregator {
if (key == previousKey) {
continue;
}
if (hardBounds == null || hardBounds.contain(key)) {
if (hardBounds == null || hardBounds.contain(key * interval)) {
long bucketOrd = bucketOrds.add(owningBucketOrd, Double.doubleToLongBits(key));
if (bucketOrd < 0) { // already seen
bucketOrd = -1 - bucketOrd;