use of com.enonic.xp.query.aggregation.metric.MaxAggregationQuery in project xp by enonic.
the class QueryAggregationParamsTest method testMetricAggregations.
@Test
public void testMetricAggregations() {
final Map<String, Object> aggregations = new HashMap<>();
aggregations.put("maxPrice", createMetricAggregationAsMap("max", "fieldName1"));
aggregations.put("minPrice", createMetricAggregationAsMap("min", "fieldName2"));
aggregations.put("countNodesWithNonEmptyPrice", createMetricAggregationAsMap("count", "fieldName3"));
final AggregationQueries result = new QueryAggregationParams().getAggregations(aggregations);
assertEquals(3, result.getSize());
result.forEach(aggregationQuery -> {
if (aggregationQuery instanceof MaxAggregationQuery) {
assertEquals("maxPrice", aggregationQuery.getName());
assertEquals("fieldName1", ((MaxAggregationQuery) aggregationQuery).getFieldName());
} else if (aggregationQuery instanceof MinAggregationQuery) {
assertEquals("minPrice", aggregationQuery.getName());
assertEquals("fieldName2", ((MinAggregationQuery) aggregationQuery).getFieldName());
} else {
assertEquals("countNodesWithNonEmptyPrice", aggregationQuery.getName());
assertEquals("fieldName3", ((ValueCountAggregationQuery) aggregationQuery).getFieldName());
}
});
}
use of com.enonic.xp.query.aggregation.metric.MaxAggregationQuery in project xp by enonic.
the class BucketAggregationQueryTest method generateSubQueries.
private List<AggregationQuery> generateSubQueries() {
final MaxAggregationQuery query1 = MaxAggregationQuery.create("query1").build();
final MinAggregationQuery query2 = MinAggregationQuery.create("query2").build();
final StatsAggregationQuery query3 = StatsAggregationQuery.create("query3").build();
final ValueCountAggregationQuery query4 = ValueCountAggregationQuery.create("query4").build();
return Arrays.asList(query1, query2, query3, query4);
}
Aggregations