org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount Java Examples
The following examples show how to use
org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount.
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 |
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: AggregationResponseHandle.java From jetlinks-community with Apache License 2.0 | 5 votes |
public static <A extends Aggregation> MetricsResponseSingleValue count(A a) { ValueCount max = (ValueCount) a; return MetricsResponseSingleValue.builder() .value(max.getValue()) .name(a.getName()) .valueAsString(max.getValueAsString()) .build(); }
Example #3
Source File: Search.java From elasticsearch-rest-command with The Unlicense | 5 votes |
public static String getValueFromAggregation(Aggregation a, Function f){ String value = null; switch(f.type){ case Function.SUM : value = String.valueOf(((Sum) a).getValue()); break; case Function.COUNT : value = String.valueOf(((ValueCount) a).getValue()); break; case Function.DC : value = String.valueOf(((Cardinality) a).getValue()); break; case Function.AVG : value = String.valueOf(((Avg) a).getValue()); break; case Function.MAX : value = String.valueOf(((Max) a).getValue()); break; case Function.MIN : value = String.valueOf(((Min) a).getValue()); break; } return value; }