Search in sources :

Example 1 with AbstractHistogramAggregationQuery

use of com.enonic.xp.query.aggregation.AbstractHistogramAggregationQuery 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;
}
Also used : AbstractRangeAggregationQuery(com.enonic.xp.query.aggregation.AbstractRangeAggregationQuery) AbstractHistogramAggregationQuery(com.enonic.xp.query.aggregation.AbstractHistogramAggregationQuery) MetricAggregationQuery(com.enonic.xp.query.aggregation.MetricAggregationQuery) TermsAggregationQuery(com.enonic.xp.query.aggregation.TermsAggregationQuery) BucketAggregationQuery(com.enonic.xp.query.aggregation.BucketAggregationQuery) AggregationQuery(com.enonic.xp.query.aggregation.AggregationQuery) MetricAggregationQuery(com.enonic.xp.query.aggregation.MetricAggregationQuery) AbstractAggregationBuilder(org.elasticsearch.search.aggregations.AbstractAggregationBuilder) TermsAggregationQuery(com.enonic.xp.query.aggregation.TermsAggregationQuery) AbstractRangeAggregationQuery(com.enonic.xp.query.aggregation.AbstractRangeAggregationQuery) AbstractHistogramAggregationQuery(com.enonic.xp.query.aggregation.AbstractHistogramAggregationQuery) HashSet(java.util.HashSet)

Aggregations

AbstractHistogramAggregationQuery (com.enonic.xp.query.aggregation.AbstractHistogramAggregationQuery)1 AbstractRangeAggregationQuery (com.enonic.xp.query.aggregation.AbstractRangeAggregationQuery)1 AggregationQuery (com.enonic.xp.query.aggregation.AggregationQuery)1 BucketAggregationQuery (com.enonic.xp.query.aggregation.BucketAggregationQuery)1 MetricAggregationQuery (com.enonic.xp.query.aggregation.MetricAggregationQuery)1 TermsAggregationQuery (com.enonic.xp.query.aggregation.TermsAggregationQuery)1 HashSet (java.util.HashSet)1 AbstractAggregationBuilder (org.elasticsearch.search.aggregations.AbstractAggregationBuilder)1