Search in sources :

Example 1 with IntervalFacetResult

use of com.rbmhtechnology.vind.api.result.facet.IntervalFacetResult 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);
}
Also used : FacetValue(com.rbmhtechnology.vind.api.result.facet.FacetValue) ArrayList(java.util.ArrayList) ParsedRange(org.elasticsearch.search.aggregations.bucket.range.ParsedRange) IntervalFacetResult(com.rbmhtechnology.vind.api.result.facet.IntervalFacetResult)

Aggregations

FacetValue (com.rbmhtechnology.vind.api.result.facet.FacetValue)1 IntervalFacetResult (com.rbmhtechnology.vind.api.result.facet.IntervalFacetResult)1 ArrayList (java.util.ArrayList)1 ParsedRange (org.elasticsearch.search.aggregations.bucket.range.ParsedRange)1