Search in sources :

Example 1 with InternalValueCount

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;
}
Also used : Aggregation(org.elasticsearch.search.aggregations.Aggregation) InternalValueCount(org.elasticsearch.search.aggregations.metrics.valuecount.InternalValueCount) FacetValue(org.sonar.server.search.FacetValue) StringTerms(org.elasticsearch.search.aggregations.bucket.terms.StringTerms) StringTerms(org.elasticsearch.search.aggregations.bucket.terms.StringTerms) Terms(org.elasticsearch.search.aggregations.bucket.terms.Terms)

Aggregations

Aggregation (org.elasticsearch.search.aggregations.Aggregation)1 StringTerms (org.elasticsearch.search.aggregations.bucket.terms.StringTerms)1 Terms (org.elasticsearch.search.aggregations.bucket.terms.Terms)1 InternalValueCount (org.elasticsearch.search.aggregations.metrics.valuecount.InternalValueCount)1 FacetValue (org.sonar.server.search.FacetValue)1