|
21 | 21 | import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
22 | 22 | import org.elasticsearch.search.aggregations.bucket.range.Range;
|
23 | 23 | import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
| 24 | +import org.elasticsearch.search.aggregations.metrics.Min; |
24 | 25 | import org.elasticsearch.search.aggregations.metrics.Sum;
|
| 26 | +import org.elasticsearch.search.aggregations.metrics.Max; |
25 | 27 | import org.elasticsearch.search.sort.SortOrder;
|
26 | 28 | import org.elasticsearch.test.ESIntegTestCase;
|
27 | 29 |
|
|
36 | 38 | import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
|
37 | 39 | import static org.elasticsearch.search.aggregations.AggregationBuilders.range;
|
38 | 40 | import static org.elasticsearch.search.aggregations.AggregationBuilders.sum;
|
| 41 | +import static org.elasticsearch.search.aggregations.AggregationBuilders.max; |
| 42 | +import static org.elasticsearch.search.aggregations.AggregationBuilders.min; |
39 | 43 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
|
40 | 44 | import static org.hamcrest.Matchers.containsString;
|
41 | 45 | import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
|
@@ -273,6 +277,20 @@ public void testAggs() {
|
273 | 277 | double expectedSum = Arrays.stream(values).mapToDouble(Number::doubleValue).sum();
|
274 | 278 | assertEquals(expectedSum, sum.getValue(), 0.001);
|
275 | 279 | }
|
| 280 | + // max agg |
| 281 | + { |
| 282 | + SearchResponse response = client().prepareSearch("idx").setSize(0).addAggregation(max("ul_max").field("ul_field")).get(); |
| 283 | + assertSearchResponse(response); |
| 284 | + Max max = response.getAggregations().get("ul_max"); |
| 285 | + assertEquals(1.8446744073709551615E19, max.getValue(), 0.001); |
| 286 | + } |
| 287 | + // min agg |
| 288 | + { |
| 289 | + SearchResponse response = client().prepareSearch("idx").setSize(0).addAggregation(min("ul_min").field("ul_field")).get(); |
| 290 | + assertSearchResponse(response); |
| 291 | + Min min = response.getAggregations().get("ul_min"); |
| 292 | + assertEquals(0, min.getValue(), 0.001); |
| 293 | + } |
276 | 294 | }
|
277 | 295 |
|
278 | 296 | public void testSortDifferentFormatsShouldFail() {
|
|
0 commit comments