|
@@ -14,6 +14,7 @@ import cn.cslg.pas.factorys.EsCountBuilderFactory.EsCountBuilderFactory;
|
|
|
import cn.cslg.pas.factorys.EsCountBuilderFactory.IEsCountBuilder;
|
|
|
import cn.cslg.pas.service.business.CommonService;
|
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
|
import co.elastic.clients.elasticsearch._types.aggregations.*;
|
|
|
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
|
@@ -213,28 +214,31 @@ public class EsCountService {
|
|
|
iEsAnalysisBuilder.setField(esConfigVO.getEsField());
|
|
|
iEsAnalysisBuilder.setTopN(topN);
|
|
|
iEsAnalysisBuilder.setIfHaveChild(ifHaveChild);
|
|
|
- for (String value : values) {
|
|
|
- if (iEsAnalysisBuilder.getField().contains(".")) {
|
|
|
- String path = iEsAnalysisBuilder.getField().substring(0, iEsAnalysisBuilder.getField().indexOf("."));
|
|
|
- iEsAnalysisBuilder.setPath(path);
|
|
|
- }
|
|
|
- iEsAnalysisBuilder.setFieldValue(value);
|
|
|
- Aggregation aggregation = iEsAnalysisBuilder.createAnalyseAgg();
|
|
|
- builder.aggregations("Agg", aggregation);
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ if (iEsAnalysisBuilder.getField().contains(".")) {
|
|
|
+ String path = iEsAnalysisBuilder.getField().substring(0, iEsAnalysisBuilder.getField().indexOf("."));
|
|
|
+ iEsAnalysisBuilder.setPath(path);
|
|
|
+ }
|
|
|
+ iEsAnalysisBuilder.setValues(values);
|
|
|
|
|
|
- Aggregate agg = response.aggregations().get("Agg");
|
|
|
- if (dateList.contains(field)) {
|
|
|
- this.getDateAnalysisDTOS(agg, field, value, topN, detailDTOS);
|
|
|
- } else if (nestedList.contains(field)) {
|
|
|
- this.getNestedCountDTOS(agg, field, detailDTOS);
|
|
|
- } else if (childList.contains(field)) {
|
|
|
+ Aggregation aggregation = iEsAnalysisBuilder.createAnalyseAgg();
|
|
|
+ builder.aggregations("Agg", aggregation);
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+
|
|
|
+ Aggregate agg = response.aggregations().get("Agg");
|
|
|
+ if (dateList.contains(field)) {
|
|
|
+// this.getDateAnalysisDTOS(agg, field, value, topN, detailDTOS);
|
|
|
+ } else if (nestedList.contains(field)) {
|
|
|
+ this.getNestedCountDTOS(agg, field, detailDTOS);
|
|
|
+ } else if (childList.contains(field)) {
|
|
|
+ for (String value : values) {
|
|
|
this.getChildAnalysisDTOS(agg, field, value, detailDTOS);
|
|
|
- } else if (numberList.contains(field)) {
|
|
|
- this.getNumberAnalysisDTOS(agg, field, value, detailDTOS);
|
|
|
- } else {
|
|
|
- this.getTermCountDTOS(agg, field, detailDTOS);
|
|
|
}
|
|
|
+ } else if (numberList.contains(field)) {
|
|
|
+// for (String value : values) {
|
|
|
+// this.getNumberAnalysisDTOS(agg, field, value, detailDTOS);
|
|
|
+// }
|
|
|
+ } else {
|
|
|
+ this.getTermCountDTOS(agg, field, detailDTOS);
|
|
|
}
|
|
|
}
|
|
|
esCountDTO.setDetailDTOS(detailDTOS);
|
|
@@ -255,6 +259,7 @@ public class EsCountService {
|
|
|
Integer topN = vo.getTopN();
|
|
|
Boolean ifHaveChild = vo.getIfHaveChild();
|
|
|
String field = vo.getField();
|
|
|
+ Integer fieldType = vo.getFieldType();
|
|
|
Aggregation aggregation = null;
|
|
|
|
|
|
builder.index("patent");
|
|
@@ -269,6 +274,7 @@ public class EsCountService {
|
|
|
iEsCountBuilder.setValueTwo(valueTwo);
|
|
|
iEsCountBuilder.setTopN(topN);
|
|
|
iEsCountBuilder.setIfHaveChild(ifHaveChild);
|
|
|
+ iEsCountBuilder.setFieldType(String.valueOf(fieldType));
|
|
|
if (iEsCountBuilder.getField().contains(".")) {
|
|
|
String path = iEsCountBuilder.getField().substring(0, iEsCountBuilder.getField().indexOf("."));
|
|
|
iEsCountBuilder.setPath(path);
|
|
@@ -392,17 +398,14 @@ public class EsCountService {
|
|
|
* @param value
|
|
|
* @param detailDTOS
|
|
|
*/
|
|
|
- public void getNumberAnalysisDTOS(Aggregate agg, String field,String value, List<EsCountDetailDTO> detailDTOS) {
|
|
|
- List<RangeBucket> list = agg.range().buckets().array();
|
|
|
- list.forEach(bucket -> {
|
|
|
- EsCountDetailDTO dto = new EsCountDetailDTO();
|
|
|
- dto.setField(field);
|
|
|
- dto.setName(value);
|
|
|
- dto.setNumber(bucket.docCount());
|
|
|
- if (dto.getNumber() > 0) {
|
|
|
- detailDTOS.add(dto);
|
|
|
- }
|
|
|
- });
|
|
|
+ public void getNumberAnalysisDTOS(Aggregate agg, String field, String value, List<EsCountDetailDTO> detailDTOS) {
|
|
|
+ EsCountDetailDTO dto = new EsCountDetailDTO();
|
|
|
+ dto.setField(field);
|
|
|
+ dto.setName(value);
|
|
|
+ dto.setNumber(agg.filter().docCount());
|
|
|
+ if (dto.getNumber() > 0) {
|
|
|
+ detailDTOS.add(dto);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|