use of org.elasticsearch.search.aggregations.metrics.valuecount.InternalValueCount in project sonarqube by SonarSource.
the class ActiveRuleIndex method processAggregations.
private static Multimap<String, FacetValue> processAggregations(@Nullable Aggregations aggregations) {
Multimap<String, FacetValue> stats = ArrayListMultimap.create();
if (aggregations == null) {
return stats;
}
for (Aggregation aggregation : aggregations.asList()) {
if (aggregation instanceof StringTerms) {
for (Terms.Bucket value : ((Terms) aggregation).getBuckets()) {
FacetValue facetValue = new FacetValue(value.getKeyAsString(), value.getDocCount());
stats.put(aggregation.getName(), facetValue);
}
} else if (aggregation instanceof InternalValueCount) {
InternalValueCount count = (InternalValueCount) aggregation;
FacetValue facetValue = new FacetValue(count.getName(), count.getValue());
stats.put(count.getName(), facetValue);
}
}
return stats;
}
Aggregations