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