소스 검색

es聚合分析统计

zero 1 년 전
부모
커밋
f067e3c143

+ 1 - 0
src/main/java/cn/cslg/pas/common/model/request/QueryRequest.java

@@ -17,5 +17,6 @@ public class QueryRequest {
     private String groupFieldValue;
     private List<OrderDTO> orderDTOList;
     private Integer projectId;
+    private Boolean ifHaveChild;
     private List<EsCustomFieldValueDTO> customFields;
 }

+ 2 - 0
src/main/java/cn/cslg/pas/common/vo/business/EsCountVO.java

@@ -12,4 +12,6 @@ public class EsCountVO {
     private String valueTwo;
     //top
     private Integer topN = 10;
+    //开关
+    private Boolean ifHaveChild;
 }

+ 25 - 2
src/main/java/cn/cslg/pas/controller/PatentController.java

@@ -1,10 +1,13 @@
 package cn.cslg.pas.controller;
 
 import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.dto.PatentDTO;
 import cn.cslg.pas.common.dto.PatentDetailDTO;
 import cn.cslg.pas.common.dto.PatentKinDTO;
 import cn.cslg.pas.common.dto.business.EsCountDTO;
+import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
 import cn.cslg.pas.common.model.cronModel.Records;
+import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.model.request.StringRequest;
 import cn.cslg.pas.common.utils.Response;
 import cn.cslg.pas.common.vo.PatentPageMessageVO;
@@ -15,6 +18,7 @@ import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
 import cn.cslg.pas.service.business.es.EsCountService;
 import cn.cslg.pas.service.business.es.EsPatentService;
+import cn.cslg.pas.service.business.es.EsService;
 import io.swagger.v3.oas.annotations.Operation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -37,6 +41,10 @@ public class PatentController {
     @Autowired
     private EsPatentService patentService;
 
+    @Autowired
+    private EsService esService;
+
+
     @Operation(summary = "查询专利")
     @PostMapping("/queryPatent")
     public Response queryPatent(@RequestBody StringRequest stringRequest) throws Exception {
@@ -47,8 +55,8 @@ public class PatentController {
 
     @Operation(summary = "统计专利库中专利")
     @PostMapping("/esCountSearch")
-    public Response esCountSearch(@RequestBody List<EsCountVO> countVOS) throws Exception {
-        EsCountDTO dto = esCountService.esCountSearch(countVOS);
+    public Response esCountSearch(@RequestBody List<EsCountVO> countVOS,String condition) throws Exception {
+        EsCountDTO dto = esCountService.esCountSearch(countVOS, condition);
         return Response.success(dto);
     }
 
@@ -72,4 +80,19 @@ public class PatentController {
       List<PatentPageMessageVO> patentPageMessageVOS= patentService.getPatentPageMessage(stringRequest);
         return Response.success(patentPageMessageVOS);
     }
+
+    @Operation(summary = "test")
+    @PostMapping("/test")
+    public Response test(@RequestBody List<EsCustomFieldValueDTO> customFields) throws Exception {
+        PatentDTO patentDTO = esService.esSearch(customFields);
+        return Response.success(patentDTO);
+    }
+
+    @Operation(summary = "esCount")
+    @PostMapping("/esCount")
+    public Response esCount(@RequestBody EsCountVO countVO) throws Exception {
+        EsCountDTO patentDTO = esCountService.esCount(countVO);
+        return Response.success(patentDTO);
+    }
+
 }

+ 29 - 6
src/main/java/cn/cslg/pas/factorys/EsCountBuilderFactory/ChildCountBuilder.java

@@ -15,26 +15,41 @@ public class ChildCountBuilder implements IEsCountBuilder{
     public String valueTwo = "";
     public Integer topN = 10;
     public String path = "";
+    public Boolean ifHaveChild = false;
 
     @Override
     public Aggregation createAggregation() {
-        Aggregation terms = AggregationBuilders.terms(j -> j.field(field).size(topN));
-        if (StringUtils.isNotEmpty(valueOne)) {
+        Aggregation terms;
+        if (ifHaveChild) {
+            Aggregation agg = AggregationBuilders.terms(i -> i.field("custom_field.stats_value.raw").size(topN));
+            terms = new Aggregation.Builder().terms(new TermsAggregation.Builder()
+                    .field(field).size(topN).build())
+                    .aggregations(new HashMap() {{
+                        put("filter_agg", agg);
+                    }}).build();
+        } else {
+            Aggregation agg = AggregationBuilders.terms(i -> i.field("custom_field.field_value.raw").size(topN));
+            terms = new Aggregation.Builder().terms(new TermsAggregation.Builder()
+                    .field(field).size(topN).build())
+                    .aggregations(new HashMap() {{
+                        put("filter_agg", agg);
+                    }}).build();
+        }
+        /*if (StringUtils.isNotEmpty(valueOne)) {
             String str = "*";
             String s = str.concat(valueOne).concat("*");
             Query query = QueryBuilders.wildcard(i -> i.field(field).value(s));
-//            Query query = QueryBuilders.term(j -> j.field(field).value(valueOne));
             Aggregation filter = AggregationBuilders.filter(n -> n.bool(k -> k.must(query)));
             terms = new Aggregation.Builder().terms(new TermsAggregation.Builder()
                     .field(field).size(topN).build())
                     .aggregations(new HashMap() {{
                         put("filter_agg", filter);
                     }}).build();
-        }
-        Aggregation finalTerms = terms;
+        }*/
+//        Aggregation finalTerms = terms;
         Aggregation aggregation = new Aggregation.Builder().children(new ChildrenAggregation.Builder()
                 .type("project_customfield").build()).aggregations(new HashMap() {{
-            put("child_agg", finalTerms);
+            put("child_agg", terms);
         }}).build();
         return aggregation;
     }
@@ -88,4 +103,12 @@ public class ChildCountBuilder implements IEsCountBuilder{
     public void setPath(String path) {
         this.path = path;
     }
+
+    public Boolean getIfHaveChild() {
+        return ifHaveChild;
+    }
+
+    public void setIfHaveChild(Boolean ifHaveChild) {
+        this.ifHaveChild = ifHaveChild;
+    }
 }

+ 9 - 0
src/main/java/cn/cslg/pas/factorys/EsCountBuilderFactory/DateHistogramBuilder.java

@@ -18,6 +18,7 @@ public class DateHistogramBuilder implements IEsCountBuilder{
     public String valueTwo = "";
     public Integer topN = 10;
     public String path = "";
+    public Boolean ifHaveChild = false;
 
     @Override
     public Aggregation createAggregation() {
@@ -74,4 +75,12 @@ public class DateHistogramBuilder implements IEsCountBuilder{
     public void setPath(String path) {
         this.path = path;
     }
+
+    public Boolean getIfHaveChild() {
+        return ifHaveChild;
+    }
+
+    public void setIfHaveChild(Boolean ifHaveChild) {
+        this.ifHaveChild = ifHaveChild;
+    }
 }

+ 11 - 0
src/main/java/cn/cslg/pas/factorys/EsCountBuilderFactory/FilterCountBuilder.java

@@ -11,6 +11,7 @@ public class FilterCountBuilder implements IEsCountBuilder{
     public String valueTwo = "";
     public Integer topN = 10;
     public String path = "";
+    public Boolean ifHaveChild = false;
 
 
     @Override
@@ -72,4 +73,14 @@ public class FilterCountBuilder implements IEsCountBuilder{
     public void setPath(String path) {
         this.path = path;
     }
+
+    @Override
+    public Boolean getIfHaveChild() {
+        return ifHaveChild;
+    }
+
+    @Override
+    public void setIfHaveChild(Boolean ifHaveChild) {
+        this.ifHaveChild = ifHaveChild;
+    }
 }

+ 5 - 0
src/main/java/cn/cslg/pas/factorys/EsCountBuilderFactory/IEsCountBuilder.java

@@ -8,6 +8,7 @@ public interface IEsCountBuilder {
     public String valueTwo = "";
     public Integer topN = 10;
     public String path = "";
+    public Boolean ifHaveChild = false;
 
     public Aggregation createAggregation();
 
@@ -30,4 +31,8 @@ public interface IEsCountBuilder {
     public String getPath();
 
     public void setPath(String path);
+
+    public Boolean getIfHaveChild();
+
+    public void setIfHaveChild(Boolean ifHaveChild);
 }

+ 11 - 0
src/main/java/cn/cslg/pas/factorys/EsCountBuilderFactory/NestedCountBuilder.java

@@ -16,6 +16,7 @@ public class NestedCountBuilder implements IEsCountBuilder {
     public String valueTwo = "";
     public Integer topN = 10;
     public String path = "";
+    public Boolean ifHaveChild = false;
 
     @Override
     public Aggregation createAggregation() {
@@ -90,4 +91,14 @@ public class NestedCountBuilder implements IEsCountBuilder {
     public void setPath(String path) {
         this.path = path;
     }
+
+    @Override
+    public Boolean getIfHaveChild() {
+        return ifHaveChild;
+    }
+
+    @Override
+    public void setIfHaveChild(Boolean ifHaveChild) {
+        this.ifHaveChild = ifHaveChild;
+    }
 }

+ 11 - 0
src/main/java/cn/cslg/pas/factorys/EsCountBuilderFactory/RangeCountBuilder.java

@@ -10,6 +10,7 @@ public class RangeCountBuilder implements IEsCountBuilder{
     public String valueTwo = "";
     public Integer topN = 10;
     public String path = "";
+    public Boolean ifHaveChild = false;
 
     @Override
     public Aggregation createAggregation() {
@@ -55,4 +56,14 @@ public class RangeCountBuilder implements IEsCountBuilder{
     public void setPath(String path) {
         this.path = path;
     }
+
+    @Override
+    public Boolean getIfHaveChild() {
+        return ifHaveChild;
+    }
+
+    @Override
+    public void setIfHaveChild(Boolean ifHaveChild) {
+        this.ifHaveChild = ifHaveChild;
+    }
 }

+ 11 - 1
src/main/java/cn/cslg/pas/factorys/EsCountBuilderFactory/TermsCountBuilder.java

@@ -18,7 +18,7 @@ public class TermsCountBuilder implements IEsCountBuilder{
     public String valueTwo = "";
     public Integer topN = 10;
     public String path = "";
-
+    public Boolean ifHaveChild = false;
     @Override
     public Aggregation createAggregation() {
         Aggregation aggregation = AggregationBuilders.terms(i -> i.field(field).size(topN));
@@ -86,4 +86,14 @@ public class TermsCountBuilder implements IEsCountBuilder{
     public void setPath(String path) {
         this.path = path;
     }
+
+    @Override
+    public Boolean getIfHaveChild() {
+        return ifHaveChild;
+    }
+
+    @Override
+    public void setIfHaveChild(Boolean ifHaveChild) {
+        this.ifHaveChild = ifHaveChild;
+    }
 }

+ 121 - 23
src/main/java/cn/cslg/pas/service/business/es/EsCountService.java

@@ -29,7 +29,7 @@ import java.util.stream.Collectors;
 @Service
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class EsCountService {
-    private final List<String> childList = Arrays.asList("childRaw");
+    private final List<String> childList = Arrays.asList("field");
     private final List<String> nestedList = Arrays.asList("PA", "IN", "PE");
     private final List<String> dateList = Arrays.asList("PD", "AD");
 
@@ -45,36 +45,19 @@ public class EsCountService {
      * @return
      * @throws Exception
      */
-    public EsCountDTO esCountSearch(List<EsCountVO> countVOS) throws Exception {
+    public EsCountDTO esCountSearch(List<EsCountVO> countVOS,String condition) throws Exception {
         EsCountDTO esCountDTO = new EsCountDTO();
         List<EsCountDetailDTO> detailDTOS = new ArrayList<>();
         for (EsCountVO vo : countVOS) {
             String field = vo.getField();
-            String valueOne = vo.getValueOne();
-            String valueTwo = vo.getValueTwo();
             Integer topN = vo.getTopN();
 
+            //查询es返回数据
             SearchRequest.Builder builder = new SearchRequest.Builder();
-            builder.index("patent");
-            IEsCountBuilder iEsCountBuilder = null;
-            String json = CommonService.readJsonFile("esCount.json");
-            List<EsConfigVO> esConfigVOS = JSON.parseArray(json, EsConfigVO.class);
-            EsConfigVO esConfigVO = esConfigVOS.stream().filter(item -> item.getField().equals(field)).findFirst().orElse(null);
-            if (esConfigVO != null) {
-                iEsCountBuilder = esCountBuilderFactory.getClass(esConfigVO.getEsClass());
-                iEsCountBuilder.setField(esConfigVO.getEsField());
-                iEsCountBuilder.setValueOne(valueOne);
-                iEsCountBuilder.setValueTwo(valueTwo);
-                iEsCountBuilder.setTopN(topN);
-                if (iEsCountBuilder.getField().contains(".")) {
-                    String path = iEsCountBuilder.getField().substring(0, iEsCountBuilder.getField().indexOf("."));
-                    iEsCountBuilder.setPath(path);
-                }
-
-            }
-            Aggregation aggregation = iEsCountBuilder.createAggregation();
+            Aggregation aggregation = this.selectAggregation(builder,vo);
             builder.aggregations("Agg", aggregation);
             SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+
             Aggregate agg = response.aggregations().get("Agg");
             if (dateList.contains(field)) {
                 List<DateHistogramBucket> list = agg.dateHistogram().buckets().array();
@@ -93,7 +76,8 @@ public class EsCountService {
                     }
                 });
                 if (!CollectionUtils.isEmpty(esCountDetailDTOS)) {
-                    List<EsCountDetailDTO> collect = esCountDetailDTOS.stream().sorted(Comparator.comparing(EsCountDetailDTO::getName).reversed()).limit(topN).collect(Collectors.toList());
+                    List<EsCountDetailDTO> collect = esCountDetailDTOS.stream().sorted(Comparator.comparing(EsCountDetailDTO::getName).reversed())
+                            .limit(topN).collect(Collectors.toList());
                     detailDTOS.addAll(collect);
                 }
             } else if (nestedList.contains(field)) {
@@ -148,4 +132,118 @@ public class EsCountService {
         esCountDTO.setDetailDTOS(detailDTOS);
         return esCountDTO;
     }
+
+    public EsCountDTO esCount(EsCountVO countVO) throws Exception {
+        EsCountDTO esCountDTO = new EsCountDTO();
+        List<EsCountDetailDTO> detailDTOS = new ArrayList<>();
+        String valueOne = countVO.getValueOne();
+        String valueTwo = countVO.getValueTwo();
+        Integer topN = countVO.getTopN();
+        String field = countVO.getField();
+
+        //查询es返回数据
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        Aggregation aggregation = this.selectAggregation(builder,countVO);
+        builder.aggregations("Agg", aggregation);
+        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        Aggregate agg = response.aggregations().get("Agg");
+        if (dateList.contains(field)) {
+            List<DateHistogramBucket> list = agg.dateHistogram().buckets().array();
+            List<EsCountDetailDTO> esCountDetailDTOS = new ArrayList<>();
+            list.forEach(bucket -> {
+                EsCountDetailDTO dto = new EsCountDetailDTO();
+                dto.setField(field);
+                Aggregate aggregate = bucket.aggregations().get("filter_agg");
+                dto.setName(bucket.keyAsString());
+                dto.setNumber(bucket.docCount());
+                if (aggregate != null) {
+                    dto.setNumber(aggregate.filter().docCount());
+                }
+                if (dto.getNumber() > 0) {
+                    esCountDetailDTOS.add(dto);
+                }
+            });
+            if (!CollectionUtils.isEmpty(esCountDetailDTOS)) {
+                List<EsCountDetailDTO> collect = esCountDetailDTOS.stream().sorted(Comparator.comparing(EsCountDetailDTO::getName).reversed()).limit(topN).collect(Collectors.toList());
+                detailDTOS.addAll(collect);
+            }
+        } else if (nestedList.contains(field)) {
+            Aggregate termsAgg = agg.nested().aggregations().get("terms_agg");
+            List<StringTermsBucket> list = termsAgg.sterms().buckets().array();
+            list.forEach(bucket -> {
+                EsCountDetailDTO dto = new EsCountDetailDTO();
+                dto.setField(field);
+                Aggregate aggregate = bucket.aggregations().get("filter_agg");
+                dto.setName(bucket.key().stringValue());
+                dto.setNumber(bucket.docCount());
+                if (aggregate != null) {
+                    dto.setNumber(aggregate.filter().docCount());
+                }
+                if (dto.getNumber() > 0) {
+                    detailDTOS.add(dto);
+                }
+            });
+        } else if (childList.contains(field)) {
+            Aggregate childAgg = agg.children().aggregations().get("child_agg");
+            List<StringTermsBucket> list = childAgg.sterms().buckets().array();
+            list.forEach(bucket -> {
+                EsCountDetailDTO dto = new EsCountDetailDTO();
+                dto.setField(field);
+                Aggregate aggregate = bucket.aggregations().get("filter_agg");
+                dto.setName(bucket.key().stringValue());
+                dto.setNumber(bucket.docCount());
+                if (aggregate != null) {
+                    dto.setNumber(aggregate.filter().docCount());
+                }
+                if (dto.getNumber() > 0) {
+                    detailDTOS.add(dto);
+                }
+            });
+        } else {
+            List<StringTermsBucket> list = agg.sterms().buckets().array();
+            list.forEach(bucket -> {
+                EsCountDetailDTO dto = new EsCountDetailDTO();
+                dto.setField(field);
+                Aggregate aggregate = bucket.aggregations().get("filter_agg");
+                dto.setName(bucket.key().stringValue());
+                dto.setNumber(bucket.docCount());
+                if (aggregate != null) {
+                    dto.setNumber(aggregate.filter().docCount());
+                }
+                if (dto.getNumber() > 0) {
+                    detailDTOS.add(dto);
+                }
+            });
+        }
+        esCountDTO.setDetailDTOS(detailDTOS);
+        return esCountDTO;
+    }
+
+    public Aggregation selectAggregation(SearchRequest.Builder builder, EsCountVO vo) {
+        String valueOne = vo.getValueOne();
+        String valueTwo = vo.getValueTwo();
+        Integer topN = vo.getTopN();
+        Boolean ifHaveChild = vo.getIfHaveChild();
+        String field = vo.getField();
+
+        builder.index("patent");
+        IEsCountBuilder iEsCountBuilder = null;
+        String json = CommonService.readJsonFile("esCount.json");
+        List<EsConfigVO> esConfigVOS = JSON.parseArray(json, EsConfigVO.class);
+        EsConfigVO esConfigVO = esConfigVOS.stream().filter(item -> item.getField().equals(field)).findFirst().orElse(null);
+        if (esConfigVO != null) {
+            iEsCountBuilder = esCountBuilderFactory.getClass(esConfigVO.getEsClass());
+            iEsCountBuilder.setField(esConfigVO.getEsField());
+            iEsCountBuilder.setValueOne(valueOne);
+            iEsCountBuilder.setValueTwo(valueTwo);
+            iEsCountBuilder.setTopN(topN);
+            iEsCountBuilder.setIfHaveChild(ifHaveChild);
+            if (iEsCountBuilder.getField().contains(".")) {
+                String path = iEsCountBuilder.getField().substring(0, iEsCountBuilder.getField().indexOf("."));
+                iEsCountBuilder.setPath(path);
+            }
+        }
+        return iEsCountBuilder.createAggregation();
+    }
+
 }

+ 36 - 26
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -132,7 +132,7 @@ public class EsService {
         String searchCondition = "";
         List<EsCustomFieldValueDTO> customFields = queryRequest.getCustomFields();
         if (!CollectionUtils.isEmpty(customFields)) {
-            searchCondition = this.parseCustomField(customFields);
+            searchCondition = this.parseCustomField(customFields,queryRequest.getIfHaveChild());
         }
         Integer projectId = queryRequest.getProjectId();
         Long current = queryRequest.getCurrent();
@@ -225,13 +225,15 @@ public class EsService {
         return dto;
     }
 
-    public PatentDTO esSearch(QueryRequest queryRequest, List<EsCustomFieldValueDTO> customFields) throws Exception {
+    public PatentDTO esSearch(List<EsCustomFieldValueDTO> customFields) throws Exception {
         PatentDTO dto = new PatentDTO();
-
+        QueryRequest queryRequest = new QueryRequest();
+        queryRequest.setCurrent(1L);
+        queryRequest.setSize(10L);
         String searchCondition = "";
 //        List<EsCustomFieldValueDTO> customFields = queryRequest.getCustomFields();
         if (!CollectionUtils.isEmpty(customFields)) {
-            searchCondition = this.parseCustomField(customFields);
+            searchCondition = this.parseCustomField(customFields,queryRequest.getIfHaveChild());
         }
         Integer projectId = queryRequest.getProjectId();
         Long current = queryRequest.getCurrent();
@@ -330,31 +332,30 @@ public class EsService {
      * @param customFields
      * @return
      */
-    public String parseCustomField(List<EsCustomFieldValueDTO> customFields) {
+    public String parseCustomField(List<EsCustomFieldValueDTO> customFields,Boolean ifHaveChild) {
         int m = 1;
         int n = 0;
         StringBuilder builder = new StringBuilder();
         long start = System.currentTimeMillis();
         if (customFields.size() > m) {
-            builder.append("(");
             for (int i = 0; i < customFields.size(); i++) {
                 EsCustomFieldValueDTO customField = customFields.get(i);
                 if (i != n) {
                     builder.append(" ").append("and").append(" ").append("(");
-                    this.appendStr(customField, builder, m);
+                    this.appendStr(customField, builder, m,ifHaveChild);
                 } else {
-                    this.appendStr(customField, builder, m);
+                    builder.append("(");
+                    this.appendStr(customField, builder, m,ifHaveChild);
                 }
             }
         } else {
             for (int i = 0; i < customFields.size(); i++) {
                 EsCustomFieldValueDTO customField = customFields.get(i);
-                int num = customFields.size() - m;
                 if (i != n) {
                     builder.append(" ").append("and").append(" ");
-                    this.appendStr(customField, builder, m);
+                    this.appendStr(customField, builder, m,ifHaveChild);
                 } else {
-                    this.appendStr(customField, builder, m);
+                    this.appendStr(customField, builder, m,ifHaveChild);
                 }
             }
         }
@@ -364,25 +365,34 @@ public class EsService {
         return builder.toString();
     }
 
-    public void appendStr(EsCustomFieldValueDTO customField, StringBuilder builder, int m) {
-        List<String> values = customField.getFieldValue();
+    public void appendStr(EsCustomFieldValueDTO customField, StringBuilder builder, int m,boolean ifHaveChild) {
         builder.append("field").append("=").append(customField.getFieldId());
-        builder.append(" ").append("and").append(" ");
-        builder.append("fieldValue").append("=");
-        if (values.size() > m) {
-            builder.append("(");
-            for (int j = 0; j < values.size(); j++) {
-                String s = values.get(j);
-                if (j != values.size() - m) {
-                    builder.append(s).append(" ").append("or").append(" ");
-                } else {
-                    builder.append(s).append(")").append(")");
+        List<String> values = customField.getFieldValue();
+        if (!CollectionUtils.isEmpty(values)) {
+            builder.append(" ").append("and").append(" ");
+            if (ifHaveChild) {
+                builder.append("statsValue").append("=");
+            } else {
+                builder.append("fieldValue").append("=");
+            }
+
+            if (values.size() > m) {
+                builder.append("(");
+                for (int j = 0; j < values.size(); j++) {
+                    String s = values.get(j);
+                    if (j != values.size() - m) {
+                        builder.append(s).append(" ").append("or").append(" ");
+                    } else {
+                        builder.append(s).append(")").append(")");
+                    }
+                }
+            } else {
+                for (String value : values) {
+                    builder.append(value);
                 }
             }
         } else {
-            for (String value : values) {
-                builder.append(value);
-            }
+            builder.append(")");
         }
     }
 

+ 27 - 4
src/main/resources/jsons/esCount.json

@@ -312,16 +312,39 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "子文档统计",
+    "name": "自定义栏位id",
     "type": "String",
-    "value": "childRaw",
-    "field": "childRaw",
+    "value": "field",
+    "field": "field",
+    "esField": "custom_field.field",
+    "esClass": "childCountBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "自定义栏位统计值",
+    "type": "String",
+    "value": "statsValue",
+    "field": "statsValue",
     "esField": "custom_field.stats_value.raw",
     "esClass": "childCountBuilder",
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "true",
     "ifAsCondition": "true"
+  },
+  {
+    "name": "自定义栏位值",
+    "type": "String",
+    "value": "fieldValue",
+    "field": "fieldValue",
+    "esField": "custom_field.field_value.raw",
+    "esClass": "childCountBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifAsCondition": "true"
   }
-
 ]

+ 12 - 1
src/main/resources/jsons/patent.json

@@ -538,6 +538,17 @@
     "ifGroup": "false",
     "ifShow": "true",
     "ifAsCondition": "true"
+  },
+  {
+    "name": "自定义栏位统计值",
+    "type": "String",
+    "value": "statsValue",
+    "field": "statsValue",
+    "esField": "custom_field.stats_value.raw",
+    "esClass": "customChildQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifAsCondition": "true"
   }
-
 ]

+ 7 - 2
src/test/java/cn/cslg/pas/service/EventServiceTests.java

@@ -244,7 +244,7 @@ public class EventServiceTests {
         vo2.setValueTwo("2023");
         countVOS.add(vo1);
 //        countVOS.add(vo2);
-        EsCountDTO esCountDTO = esCountService.esCountSearch(countVOS);
+        EsCountDTO esCountDTO = esCountService.esCountSearch(countVOS, "");
         System.out.println(esCountDTO);
 
     }
@@ -307,7 +307,7 @@ public class EventServiceTests {
         dto2.setFieldValue(Arrays.asList("a", "b"));
         customFields.add(dto1);
         customFields.add(dto2);
-        String s = esService.parseCustomField(customFields);
+        String s = esService.parseCustomField(customFields,Boolean.FALSE);
         System.out.println("结果为:" + s);
         System.out.println("-----------------------------");
         List<EsCustomFieldValueDTO> fields = new ArrayList<>();
@@ -323,4 +323,9 @@ public class EventServiceTests {
         SelectClaimDTO dto = esService.selectPatentNo(list);
         System.out.println(dto);
     }
+
+    @Test
+    void test18() {
+//        esService
+    }
 }