use of com.enonic.xp.query.aggregation.MetricAggregationQuery in project xp by enonic.
the class AggregationQueryBuilderFactory method doCreate.
private Set<AbstractAggregationBuilder> doCreate(final AggregationQueries aggregationQueries) {
Set<AbstractAggregationBuilder> aggregationBuilders = new HashSet<>();
for (final AggregationQuery aggregationQuery : aggregationQueries) {
final AbstractAggregationBuilder aggregationBuilder;
if (aggregationQuery instanceof TermsAggregationQuery) {
aggregationBuilder = new TermsAggregationQueryBuilderFactory(fieldNameResolver).create((TermsAggregationQuery) aggregationQuery);
} else if (aggregationQuery instanceof AbstractRangeAggregationQuery) {
aggregationBuilder = new RangeAggregationQueryBuilderFactory(fieldNameResolver).create((AbstractRangeAggregationQuery) aggregationQuery);
} else if (aggregationQuery instanceof AbstractHistogramAggregationQuery) {
aggregationBuilder = new HistogramAggregationQueryBuilderFactory(fieldNameResolver).create((AbstractHistogramAggregationQuery) aggregationQuery);
} else if (aggregationQuery instanceof MetricAggregationQuery) {
aggregationBuilder = new MetricAggregationQueryBuilderFactory(fieldNameResolver).create((MetricAggregationQuery) aggregationQuery);
} else {
throw new IllegalArgumentException("Unexpected aggregation type: " + aggregationQuery.getClass());
}
handleSubAggregations(aggregationQuery, aggregationBuilder);
aggregationBuilders.add(aggregationBuilder);
}
return aggregationBuilders;
}
Aggregations