Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,15 @@ private static void traverseAggregationResults(
if ((keys.size() > 1) && (agg.containsKey(keys.get(1)))) {
// If the current node in the aggregation tree does not have further buckets
// but contains the next level of aggregation, it means we are in the nested
// aggregation
// aggregation. Nested aggregations are structural and don't produce bucket
// keys, so we pass dimensions through unchanged.
traverseAggregationResults(
agg,
reportData,
nodeData,
keys.subList(1, keys.size()),
metric,
dimensions.subList(1, dimensions.size()));
agg, reportData, nodeData, keys.subList(1, keys.size()), metric, dimensions);
} else {
// If the current node in the aggregation tree does not have further bucket
// it means we are in the leaf of the metric aggregation. We'll add the metric
handleLeafMetricsAggregation(agg, reportData, nodeData, metric);
}
// If the current node in the aggregation tree does not have further bucket
// it means we are in the leaf of the metric aggregation. We'll add the metric
handleLeafMetricsAggregation(agg, reportData, nodeData, metric);
} else {
buckets
.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,29 @@ public class ElasticNestedAggregations implements ElasticAggregations {
private String aggregationName;
private Aggregation aggregation;
private Map<String, Aggregation> subAggregations = new HashMap<>();
private String path;

@Override
public void createAggregation(SearchAggregationNode node) {
Map<String, String> params = node.getValue();
this.aggregationName = node.getName();
this.path = params.get("path");
this.aggregation =
Aggregation.of(
a -> a.nested(NestedAggregation.of(nested -> nested.path(params.get("path")))));
Aggregation.of(a -> a.nested(NestedAggregation.of(nested -> nested.path(path))));
}

@Override
public void setSubAggregations(Map<String, Aggregation> subAggregations) {
this.subAggregations = subAggregations;
this.aggregation =
Aggregation.of(
a ->
a.nested(NestedAggregation.of(nested -> nested.path(path)))
.aggregations(subAggregations));
}

@Override
public Boolean supportsSubAggregationsNatively() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ public class OpenDateHistogramAggregations implements OpenAggregations {
private String aggregationName;
private Aggregation aggregation;
private Map<String, Aggregation> subAggregations = new HashMap<>();
private String field;
private CalendarInterval calendarInterval;

@Override
public void createAggregation(SearchAggregationNode node) {
Map<String, String> params = node.getValue();
this.aggregationName = node.getName();

String field = params.get("field");
String calendarInterval = params.get("calendar_interval");
this.field = params.get("field");
this.calendarInterval = mapCalendarInterval(params.get("calendar_interval"));

this.aggregation =
Aggregation.of(
a ->
a.dateHistogram(
DateHistogramAggregation.of(
dh ->
dh.field(field)
.calendarInterval(mapCalendarInterval(calendarInterval)))));
dh -> dh.field(field).calendarInterval(calendarInterval))));
}

private CalendarInterval mapCalendarInterval(String interval) {
Expand All @@ -51,5 +51,17 @@ private CalendarInterval mapCalendarInterval(String interval) {
@Override
public void setSubAggregations(Map<String, Aggregation> subAggregations) {
this.subAggregations = subAggregations;
this.aggregation =
Aggregation.of(
a ->
a.dateHistogram(
DateHistogramAggregation.of(
dh -> dh.field(field).calendarInterval(calendarInterval)))
.aggregations(subAggregations));
}

@Override
public Boolean supportsSubAggregationsNatively() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,29 @@ public class OpenNestedAggregations implements OpenAggregations {
private String aggregationName;
private Aggregation aggregation;
private Map<String, Aggregation> subAggregations = new HashMap<>();
private String path;

@Override
public void createAggregation(SearchAggregationNode node) {
Map<String, String> params = node.getValue();
this.aggregationName = node.getName();
this.path = params.get("path");
this.aggregation =
Aggregation.of(
a -> a.nested(NestedAggregation.of(nested -> nested.path(params.get("path")))));
Aggregation.of(a -> a.nested(NestedAggregation.of(nested -> nested.path(path))));
}

@Override
public void setSubAggregations(Map<String, Aggregation> subAggregations) {
this.subAggregations = subAggregations;
this.aggregation =
Aggregation.of(
a ->
a.nested(NestedAggregation.of(nested -> nested.path(path)))
.aggregations(subAggregations));
}

@Override
public Boolean supportsSubAggregationsNatively() {
return true;
}
}
Loading
Loading