예제 #1
0
 // Response helpers
 protected Multimap<String, FacetValue> processAggregations(Aggregations aggregations) {
   Multimap<String, FacetValue> stats = ArrayListMultimap.create();
   if (aggregations != null) {
     for (Aggregation aggregation : aggregations.asList()) {
       if (aggregation instanceof StringTerms) {
         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;
 }