use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.bucket.range.DateRangeAggregationBuilder in project graylog2-server by Graylog2.
the class ESDateRangeHandler method doCreateAggregation.
@Nonnull
@Override
public Optional<AggregationBuilder> doCreateAggregation(String name, Pivot pivot, DateRangeBucket dateRangeBucket, ESPivot searchTypeHandler, ESGeneratedQueryContext esGeneratedQueryContext, Query query) {
final DateRangeAggregationBuilder builder = AggregationBuilders.dateRange(name).field(dateRangeBucket.field());
dateRangeBucket.ranges().forEach(r -> {
final String from = r.from().map(AbstractDateTime::toString).orElse(null);
final String to = r.to().map(AbstractDateTime::toString).orElse(null);
if (from != null && to != null) {
builder.addRange(from, to);
} else if (to != null) {
builder.addUnboundedTo(to);
} else if (from != null) {
builder.addUnboundedFrom(from);
}
});
builder.format("date_time");
builder.keyed(false);
record(esGeneratedQueryContext, pivot, dateRangeBucket, name, ParsedDateRange.class);
return Optional.of(builder);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.bucket.range.DateRangeAggregationBuilder in project graylog2-server by Graylog2.
the class ESDateRangeHandler method doCreateAggregation.
@Nonnull
@Override
public Optional<AggregationBuilder> doCreateAggregation(String name, Pivot pivot, DateRangeBucket dateRangeBucket, ESPivot searchTypeHandler, ESGeneratedQueryContext esGeneratedQueryContext, Query query) {
final DateRangeAggregationBuilder builder = AggregationBuilders.dateRange(name).field(dateRangeBucket.field());
dateRangeBucket.ranges().forEach(r -> {
final String from = r.from().map(AbstractDateTime::toString).orElse(null);
final String to = r.to().map(AbstractDateTime::toString).orElse(null);
if (from != null && to != null) {
builder.addRange(from, to);
} else if (to != null) {
builder.addUnboundedTo(to);
} else if (from != null) {
builder.addUnboundedFrom(from);
}
});
builder.format("date_time");
builder.keyed(false);
record(esGeneratedQueryContext, pivot, dateRangeBucket, name, DateRangeAggregation.class);
return Optional.of(builder);
}
Aggregations