use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.BucketOrder in project graylog2-server by Graylog2.
the class ESTimeHandler method doCreateAggregation.
@Nonnull
@Override
public Optional<AggregationBuilder> doCreateAggregation(String name, Pivot pivot, Time timeSpec, ESPivot searchTypeHandler, ESGeneratedQueryContext esGeneratedQueryContext, Query query) {
final DateHistogramInterval dateHistogramInterval = new DateHistogramInterval(timeSpec.interval().toDateInterval(query.effectiveTimeRange(pivot)).toString());
final Optional<BucketOrder> ordering = orderForPivot(pivot, timeSpec, esGeneratedQueryContext);
final DateHistogramAggregationBuilder builder = AggregationBuilders.dateHistogram(name).dateHistogramInterval(dateHistogramInterval).field(timeSpec.field()).order(ordering.orElse(BucketOrder.key(true))).format("date_time");
record(esGeneratedQueryContext, pivot, timeSpec, name, DateHistogramAggregation.class);
return Optional.of(builder);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.BucketOrder in project graylog2-server by Graylog2.
the class ESValuesHandler method doCreateAggregation.
@Nonnull
@Override
public Optional<AggregationBuilder> doCreateAggregation(String name, Pivot pivot, Values valuesSpec, ESPivot searchTypeHandler, ESGeneratedQueryContext esGeneratedQueryContext, Query query) {
final List<BucketOrder> ordering = orderListForPivot(pivot, valuesSpec, esGeneratedQueryContext);
final TermsAggregationBuilder builder = AggregationBuilders.terms(name).minDocCount(1).field(valuesSpec.field()).order(ordering.isEmpty() ? Collections.singletonList(BucketOrder.count(false)) : ordering).size(valuesSpec.limit());
record(esGeneratedQueryContext, pivot, valuesSpec, name, TermsAggregation.class);
return Optional.of(builder);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.BucketOrder in project graylog2-server by Graylog2.
the class ESValuesHandler method doCreateAggregation.
@Nonnull
@Override
public Optional<AggregationBuilder> doCreateAggregation(String name, Pivot pivot, Values valuesSpec, ESPivot searchTypeHandler, ESGeneratedQueryContext esGeneratedQueryContext, Query query) {
final List<BucketOrder> ordering = orderListForPivot(pivot, valuesSpec, esGeneratedQueryContext);
final TermsAggregationBuilder builder = AggregationBuilders.terms(name).minDocCount(1).field(valuesSpec.field()).order(ordering.isEmpty() ? Collections.singletonList(BucketOrder.count(false)) : ordering).size(valuesSpec.limit());
record(esGeneratedQueryContext, pivot, valuesSpec, name, Terms.class);
return Optional.of(builder);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.BucketOrder in project graylog2-server by Graylog2.
the class ESTimeHandler method doCreateAggregation.
@Nonnull
@Override
public Optional<AggregationBuilder> doCreateAggregation(String name, Pivot pivot, Time timeSpec, ESPivot searchTypeHandler, ESGeneratedQueryContext esGeneratedQueryContext, Query query) {
final DateHistogramInterval dateHistogramInterval = new DateHistogramInterval(timeSpec.interval().toDateInterval(query.effectiveTimeRange(pivot)).toString());
final Optional<BucketOrder> ordering = orderForPivot(pivot, timeSpec, esGeneratedQueryContext);
final DateHistogramAggregationBuilder builder = AggregationBuilders.dateHistogram(name).field(timeSpec.field()).order(ordering.orElse(BucketOrder.key(true))).format("date_time");
setInterval(builder, dateHistogramInterval);
record(esGeneratedQueryContext, pivot, timeSpec, name, ParsedDateHistogram.class);
return Optional.of(builder);
}
Aggregations