org.elasticsearch.search.aggregations.metrics.stats.StatsAggregationBuilder Java Examples
The following examples show how to use
org.elasticsearch.search.aggregations.metrics.stats.StatsAggregationBuilder.
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: StatsAggregationMain.java From elasticsearch-pool with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws IOException { RestHighLevelClient client = HighLevelClient.getInstance(); try{ QueryBuilder matchQueryBuilder = QueryBuilders.matchQuery("cmd", "weather_hourforcast"); StatsAggregationBuilder aggregationBuilder = AggregationBuilders.stats("utm_stats").field("utm").missing(0); SearchRequest searchRequest = new SearchRequest("serverlog_20180710");//限定index searchRequest.types("log");//限定type SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); searchSourceBuilder.query(matchQueryBuilder); searchSourceBuilder.aggregation(aggregationBuilder); searchSourceBuilder.size(0); searchRequest.source(searchSourceBuilder); SearchResponse searchResponse = client.search(searchRequest); System.out.println(searchResponse); }finally{ HighLevelClient.close(); } }
Example #2
Source File: AggregationHelper.java From fast-elasticsearch-query-builder with Apache License 2.0 | 5 votes |
private static void setStatsAggregation(SearchSourceBuilder searchSource, StatsAggregation aggregation, Boolean value) { if (!value) { return; } StatsAggregationBuilder statsAggregation = new StatsAggregationBuilder(aggregation.name()).field(aggregation.field()); searchSource.aggregation(statsAggregation); }