for (Terms.Bucket value : ((Terms) aggregation).getBuckets()) {
FacetValue facetValue = new FacetValue(value.getKey(), 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;
}