Open zhouliangiseeyou opened 3 months ago
moonbox-server/moonbox-service-data-es/src/main/java/com/vivo/internet/moonbox/service/data/es/record/service/RecordDataServiceImpl.java
` @Override public List getRecordUriCountList(RecordUriCountQuery query) { SearchRequest searchRequest = new SearchRequest(INDEX_NAME).indicesOptions(IndicesOptions.lenientExpandOpen()) .preference("_local");
List<CompositeValuesSourceBuilder<?>> aggBuilder = Lists.newArrayList(); aggBuilder.add(new TermsValuesSourceBuilder("uri").field(EsRecordEntity.Fields.entranceDesc)); SearchSourceBuilder sourceBuilder = new SearchSourceBuilder().size(0) .query(QueryBuilders.boolQuery().filter( QueryBuilders.termQuery(EsRecordEntity.Fields.recordTaskRunId, query.getRecordTaskRunId()))); if (StringUtils.isNotBlank(query.getUriMatchCondition())) { sourceBuilder.query(QueryBuilders.boolQuery().filter( QueryBuilders.termQuery(EsReplayEntity.Fields.entranceDesc, query.getUriMatchCondition()))); } sourceBuilder.aggregation(new CompositeAggregationBuilder("myBuckets", aggBuilder).size(1000)); searchRequest.source(sourceBuilder); // 获取聚合查询结果 SearchResponse r = search(searchRequest); ParsedComposite parsedComposite = r.getAggregations().get("myBuckets"); if (CollectionUtils.isEmpty(parsedComposite.getBuckets())) { return Lists.newArrayList(); } return parsedComposite.getBuckets().stream().map(item -> { Map<String, Object> keys = item.getKey(); return RecordUriCountResult.builder().recordUri(keys.get("uri").toString()) .recordTaskRunId(query.getRecordTaskRunId()).recordCount(item.getDocCount()) .invokeType(InvokeType.getInvokeTypeByUri(keys.get("uri").toString()).getInvokeName()).build(); }).collect(Collectors.toList()); }`
` @Override public List getRecordUriCountList(RecordUriCountQuery query) {
SearchRequest searchRequest = new SearchRequest(INDEX_NAME).indicesOptions(IndicesOptions.lenientExpandOpen())
.preference("_local");