org.elasticsearch.search.aggregations.metrics.sum.SumBuilder Java Examples
The following examples show how to use
org.elasticsearch.search.aggregations.metrics.sum.SumBuilder.
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: EsEntityIndexImpl.java From usergrid with Apache License 2.0 | 6 votes |
private long getEntitySizeAggregation( final SearchRequestBuilder builder ) { final String key = "entitySize"; SumBuilder sumBuilder = new SumBuilder(key); sumBuilder.field("entitySize"); builder.addAggregation(sumBuilder); Observable<Number> o = Observable.from(builder.execute()) .map(response -> { Sum aggregation = (Sum) response.getAggregations().get(key); if(aggregation == null){ return -1; }else{ return aggregation.getValue(); } }); Number val = ObservableTimer.time(o,aggregationTimer).toBlocking().lastOrDefault(-1); return val.longValue(); }
Example #2
Source File: AST_Stats.java From elasticsearch-rest-command with The Unlicense | 5 votes |
public static AbstractAggregationBuilder newSum(Function func) { SumBuilder sum; if (func.fieldtype == Field.SCRIPT) sum = AggregationBuilders.sum(Function.genStatField(func)) .script(func.field); else sum = AggregationBuilders.sum(Function.genStatField(func)) .field(func.field); return sum; }
Example #3
Source File: AggregationBuilders.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * Create a new {@link Sum} aggregation with the given name. */ public static SumBuilder sum(String name) { return new SumBuilder(name); }