use of org.elasticsearch.search.aggregations.bucket.range.ParsedRange in project vind by RBMHTechnology.
the class ResultUtils method getIntervalFacetResults.
private static Pair<String, IntervalFacetResult> getIntervalFacetResults(Aggregation aggregation, Facet.IntervalFacet intervalFacet) {
final List<FacetValue<String>> values = new ArrayList<>();
Optional.ofNullable(aggregation).ifPresent(agg -> ((ParsedRange) agg).getBuckets().stream().map(bucket -> new FacetValue(bucket.getKey(), bucket.getDocCount())).forEach(values::add));
final IntervalFacetResult intervalFacetResult = new IntervalFacetResult(values);
return Pair.of(intervalFacet.getFacetName(), intervalFacetResult);
}
Aggregations