use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.AggregationBuilder 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);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.AggregationBuilder in project graylog2-server by Graylog2.
the class ESSumHandler method doCreateAggregation.
@Nonnull
@Override
public Optional<AggregationBuilder> doCreateAggregation(String name, Pivot pivot, Sum sumSpec, ESPivot searchTypeHandler, ESGeneratedQueryContext queryContext) {
final SumAggregationBuilder sum = AggregationBuilders.sum(name).field(sumSpec.field());
record(queryContext, pivot, sumSpec, name, org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.metrics.Sum.class);
return Optional.of(sum);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.AggregationBuilder in project graylog2-server by Graylog2.
the class ESLatestHandler method doCreateAggregation.
@Nonnull
@Override
public Optional<AggregationBuilder> doCreateAggregation(String name, Pivot pivot, Latest latestSpec, ESPivot searchTypeHandler, ESGeneratedQueryContext queryContext) {
final TopHitsAggregationBuilder latest = AggregationBuilders.topHits(name).size(1).sort(SortBuilders.fieldSort("timestamp").order(SortOrder.DESC));
record(queryContext, pivot, latestSpec, name, TopHits.class);
return Optional.of(latest);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.AggregationBuilder in project graylog2-server by Graylog2.
the class ESMinHandler method doCreateAggregation.
@Nonnull
@Override
public Optional<AggregationBuilder> doCreateAggregation(String name, Pivot pivot, Min minSpec, ESPivot searchTypeHandler, ESGeneratedQueryContext queryContext) {
final MinAggregationBuilder min = AggregationBuilders.min(name).field(minSpec.field());
record(queryContext, pivot, minSpec, name, org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.metrics.Min.class);
return Optional.of(min);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.AggregationBuilder in project graylog2-server by Graylog2.
the class ESStdDevHandler method doCreateAggregation.
@Nonnull
@Override
public Optional<AggregationBuilder> doCreateAggregation(String name, Pivot pivot, StdDev stddevSpec, ESPivot searchTypeHandler, ESGeneratedQueryContext queryContext) {
final ExtendedStatsAggregationBuilder stddev = AggregationBuilders.extendedStats(name).field(stddevSpec.field());
record(queryContext, pivot, stddevSpec, name, ExtendedStats.class);
return Optional.of(stddev);
}
Aggregations