org.elasticsearch.search.aggregations.bucket.range.Range Java Examples

The following examples show how to use org.elasticsearch.search.aggregations.bucket.range.Range. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AggregationResponseHandle.java    From jetlinks-community with Apache License 2.0 6 votes vote down vote up
private static <A extends Aggregation> void route(Bucket bucket, A a) {
    if (a instanceof Terms) {
        bucket.setBuckets(terms(a));
    } else if (a instanceof Range) {
        bucket.setBuckets(range(a));
    } else if (a instanceof Histogram) {
        bucket.setBuckets(range(a));
    } else if (a instanceof Avg) {
        bucket.setAvg(avg(a));
    } else if (a instanceof Min) {
        bucket.setMin(min(a));
    } else if (a instanceof Max) {
        bucket.setMax(max(a));
    } else if (a instanceof Sum) {
        bucket.setSum(sum(a));
    } else if (a instanceof Stats) {
        stats(bucket, a);
    }  else if (a instanceof ValueCount) {
        bucket.setValueCount(count(a));
    } else {
        throw new UnsupportedOperationException("不支持的聚合类型");
    }
}
 
Example #2
Source File: AggregationServiceImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
/**
 * 赋值当天统计
 */
private void setCurrDate(Map<String, Object> result, Aggregations aggregations) {
    ParsedDateRange currDate = aggregations.get("currDate");
    Range.Bucket bucket = currDate.getBuckets().get(0);
    Cardinality cardinality = bucket.getAggregations().get("uv");
    result.put("currDate_pv", bucket.getDocCount());
    result.put("currDate_uv", cardinality.getValue());
}
 
Example #3
Source File: AggregationServiceImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
/**
 * 赋值周统计
 */
private void setCurr24Hour(Map<String, Object> result, Aggregations aggregations) {
    ParsedDateRange curr24Hour = aggregations.get("curr24Hour");
    Range.Bucket bucket = curr24Hour.getBuckets().get(0);
    //赋值天趋势统计
    setStatDate(result, bucket.getAggregations());
}
 
Example #4
Source File: AggregationServiceImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
/**
 * 赋值周统计
 */
private void setCurrWeek(Map<String, Object> result, Aggregations aggregations) {
    ParsedDateRange currWeek = aggregations.get("currWeek");
    Range.Bucket bucket = currWeek.getBuckets().get(0);
    result.put("currWeek_pv", bucket.getDocCount());
    //赋值周趋势统计
    setStatWeek(result, bucket.getAggregations());
}
 
Example #5
Source File: AggregationServiceImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
/**
 * 赋值小时内统计-当前在线数
 */
private void setCurrHour(Map<String, Object> result, Aggregations aggregations) {
    ParsedDateRange currDate = aggregations.get("currHour");
    Range.Bucket bucket = currDate.getBuckets().get(0);
    Cardinality cardinality = bucket.getAggregations().get("uv");
    result.put("currHour_uv", cardinality.getValue());
}
 
Example #6
Source File: JdbcResponseExtractor.java    From elasticsearch-sql with MIT License 5 votes vote down vote up
private void parseRangeAggregation(Aggregation aggregation, Map<String, Object> aggMap) {
    Range range = (Range) aggregation;
    List<Map<String, Object>> rangeList = new ArrayList<>(0);
    for (Range.Bucket bucket : range.getBuckets()) {
        Map<String, Object> rangeItem = new HashMap<>(0);
        rangeItem.put(bucket.getKeyAsString(), bucket.getDocCount());
        rangeList.add(rangeItem);
    }
    aggMap.put(range.getName(), rangeList);
}
 
Example #7
Source File: AggregationServiceImpl.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
/**
 * 赋值月统计
 */
private void setCurrMonth(Map<String, Object> result, Aggregations aggregations) {
    ParsedDateRange currMonth = aggregations.get("currMonth");
    Range.Bucket bucket = currMonth.getBuckets().get(0);
    result.put("currMonth_pv", bucket.getDocCount());
}