org.elasticsearch.search.aggregations.bucket.histogram.ExtendedBounds Java Examples
The following examples show how to use
org.elasticsearch.search.aggregations.bucket.histogram.ExtendedBounds.
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: ElasticsearchHelperService.java From xmfcn-spring-cloud with Apache License 2.0 | 5 votes |
/** * 按天统计 各个日志级别的数量 查询条件 * * @param EsModel es * keywords * highlights * @return */ public Search statisticsDayCondition(EsModel es) { Search search = null; if (es == null) { return search; } String indexName = es.getIndex(); String type = es.getType(); String startTime = es.getStartTime(); String endTime = es.getEndTime(); JSONObject keywords = es.getKeyWord(); if (StringUtil.isBlank(indexName)) { return search; } if (StringUtil.isBlank(type)) { return search; } SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); if (StringUtil.isNotBlank(startTime) && StringUtil.isNotBlank(endTime)) { RangeQueryBuilder rangequerybuilder = QueryBuilders .rangeQuery("createTime") .from(startTime).to(endTime); searchSourceBuilder.query(rangequerybuilder); } AddKeyWords(keywords, searchSourceBuilder); ExtendedBounds extendedBounds = new ExtendedBounds(startTime, endTime); AggregationBuilder levelAgg = AggregationBuilders.terms("level_count").field("level").minDocCount(0); AggregationBuilder dateAgg = AggregationBuilders.dateHistogram("day_count") .field("createTime") .dateHistogramInterval(DateHistogramInterval.DAY) .format("yyyy-MM-dd") .extendedBounds(extendedBounds) .minDocCount(0L)//为空0补充 .timeZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("GMT+8"))); AggregationBuilder builder = dateAgg.subAggregation(levelAgg); searchSourceBuilder.aggregation(builder).size(0); search = new Search.Builder(searchSourceBuilder.toString()) .addIndex(indexName).addType(type).build(); return search; }
Example #2
Source File: ElasticsearchHelperService.java From xmfcn-spring-cloud with Apache License 2.0 | 5 votes |
/** * 按天Level统计 各个日志级别的数量 查询条件 * * @param EsModel es * keywords * highlights * @return */ public Search statisticsLevelCondition(EsModel es) { Search search = null; if (es == null) { return search; } String indexName = es.getIndex(); String type = es.getType(); String startTime = es.getStartTime(); String endTime = es.getEndTime(); JSONObject keywords = es.getKeyWord(); if (StringUtil.isBlank(indexName)) { return search; } if (StringUtil.isBlank(type)) { return search; } SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); if (StringUtil.isNotBlank(startTime) && StringUtil.isNotBlank(endTime)) { RangeQueryBuilder rangequerybuilder = QueryBuilders .rangeQuery("createTime") .from(startTime).to(endTime); searchSourceBuilder.query(rangequerybuilder); } AddKeyWords(keywords, searchSourceBuilder); ExtendedBounds extendedBounds = new ExtendedBounds(startTime, endTime); AggregationBuilder levelAgg = AggregationBuilders.terms("level_count").field("level").minDocCount(0); searchSourceBuilder.aggregation(levelAgg).size(0); search = new Search.Builder(searchSourceBuilder.toString()) .addIndex(indexName).addType(type).build(); return search; }
Example #3
Source File: DefaultAggregationService.java From jetlinks-community with Apache License 2.0 | 4 votes |
protected static ExtendedBounds getExtendedBounds(AggregationQueryParam param) { return new ExtendedBounds(calculateStartWithTime(param), param.getEndWithTime()); }