|
@@ -21,6 +21,7 @@ import co.elastic.clients.elasticsearch._types.aggregations.*;
|
|
|
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
|
|
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
|
|
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
|
|
+import co.elastic.clients.elasticsearch.core.search.Hit;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -184,7 +185,7 @@ public class EsCountService {
|
|
|
}
|
|
|
String format = countVO.getFormat();
|
|
|
List<String> values = countVO.getValues();
|
|
|
- Aggregation aggregation = this.getAggregation(countVO,projectId);
|
|
|
+ Aggregation aggregation = this.getAggregation(countVO, projectId, taskId);
|
|
|
if (query != null) {
|
|
|
Query finalQuery = query;
|
|
|
Aggregation finalAggregation = aggregation;
|
|
@@ -415,7 +416,7 @@ public class EsCountService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public Aggregation getAggregation(EsCountVO countVO,Integer projectId) throws Exception {
|
|
|
+ public Aggregation getAggregation(EsCountVO countVO, Integer projectId, Integer taskId) throws Exception {
|
|
|
String field = countVO.getField();
|
|
|
Integer topN = countVO.getTopN();
|
|
|
Boolean ifHaveChild = countVO.getIfHaveChild();
|
|
@@ -448,6 +449,7 @@ public class EsCountService {
|
|
|
iEsCountAnalysisBuilder.setTopN(topN);
|
|
|
iEsCountAnalysisBuilder.setFormat(format);
|
|
|
iEsCountAnalysisBuilder.setProjectId(projectId);
|
|
|
+ iEsCountAnalysisBuilder.setTaskId(taskId);
|
|
|
iEsCountAnalysisBuilder.setIfHaveChild(ifHaveChild);
|
|
|
if (iEsCountAnalysisBuilder.getField().contains(".")) {
|
|
|
String path = iEsCountAnalysisBuilder.getField()
|
|
@@ -620,6 +622,32 @@ public class EsCountService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public Integer getUnselectedCustomNum(Integer projectId,Integer taskId) throws Exception {
|
|
|
+ String condition = "";
|
|
|
+ if (taskId != null) {
|
|
|
+ condition = "taskId = " + taskId;
|
|
|
+ } else {
|
|
|
+ condition = "projectId = " + projectId;
|
|
|
+ }
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent");
|
|
|
+ treeNode tree = expressManager.getInstance().Parse(condition, false);
|
|
|
+ //格式化检索式
|
|
|
+ //3. 从es中检索数据
|
|
|
+ Query q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent");
|
|
|
+ builder.query(q);
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
+ Long total = response.hits().total().value();
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ for (Hit<Patent> hit : hits) {
|
|
|
+ String id = hit.id();
|
|
|
+ list.add(id);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取children分析后数据
|
|
|
*
|
|
@@ -987,14 +1015,17 @@ public class EsCountService {
|
|
|
EsCountDetailDTO dto = new EsCountDetailDTO();
|
|
|
dto.setField(field);
|
|
|
Aggregate aggregate = bucket.aggregations().get("filter_agg");
|
|
|
- dto.setName(bucket.key().stringValue());
|
|
|
- dto.setNumber(bucket.docCount());
|
|
|
- dto.setTopN(topN);
|
|
|
- dto.setFirstName(firstName);
|
|
|
- if (aggregate != null) {
|
|
|
- dto.setNumber(aggregate.filter().docCount());
|
|
|
+ String value = bucket.key().stringValue();
|
|
|
+ if (StringUtils.isNotEmpty(value)) {
|
|
|
+ dto.setName(value);
|
|
|
+ dto.setNumber(bucket.docCount());
|
|
|
+ dto.setTopN(topN);
|
|
|
+ dto.setFirstName(firstName);
|
|
|
+ if (aggregate != null) {
|
|
|
+ dto.setNumber(aggregate.filter().docCount());
|
|
|
+ }
|
|
|
+ countDetailDTOS.add(dto);
|
|
|
}
|
|
|
- countDetailDTOS.add(dto);
|
|
|
// if (dto.getNumber() > 0) {
|
|
|
// detailDTOS.add(dto);
|
|
|
// }
|