zero 9 miesięcy temu
rodzic
commit
4a8cb68bdd

+ 1 - 6
src/main/java/cn/cslg/pas/controller/PatentController.java

@@ -103,12 +103,7 @@ public class PatentController {
     @PostMapping("/queryPatent")
     public Response queryPatent(@RequestBody StringRequest stringRequest) throws Exception {
         Business business = businessFactory.getClass("patentService");
-        Records records = null;
-        try {
-            records = (Records) business.queryMessage(stringRequest);
-        } catch (Exception e) {
-            return Response.error(e.getMessage());
-        }
+        Records records = (Records) business.queryMessage(stringRequest);
         return Response.success(records);
     }
 

+ 1 - 1
src/main/java/cn/cslg/pas/service/ReportExportService.java

@@ -1034,7 +1034,7 @@ public class ReportExportService {
                 patent = patentList.get(0);
             }
         } catch (Exception e) {
-            throw new IOException();
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "获取标的专利信息失败");
         }
 
         //装载单个专利的信息

+ 32 - 9
src/main/java/cn/cslg/pas/service/business/MergePersonService.java

@@ -19,6 +19,7 @@ import cn.cslg.pas.domain.business.FollowUp;
 import cn.cslg.pas.domain.business.MergePerson;
 import cn.cslg.pas.domain.business.SystemDict;
 import cn.cslg.pas.domain.es.*;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.MergePersonMapper;
@@ -29,10 +30,7 @@ import cn.cslg.pas.service.query.FormatQueryService;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.PageUtil;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
-import co.elastic.clients.elasticsearch._types.FieldValue;
-import co.elastic.clients.elasticsearch._types.InlineScript;
-import co.elastic.clients.elasticsearch._types.Refresh;
-import co.elastic.clients.elasticsearch._types.Script;
+import co.elastic.clients.elasticsearch._types.*;
 import co.elastic.clients.elasticsearch._types.aggregations.*;
 import co.elastic.clients.elasticsearch._types.query_dsl.IdsQuery;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
@@ -417,7 +415,12 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
         builder.query(query);
         builder.size(1000);
         builder.trackTotalHits(TrackHits.of(i -> i.enabled(true)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().hits();
     }
 
@@ -458,7 +461,12 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
         builder.query(query);
         builder.size(1000);
         builder.trackTotalHits(TrackHits.of(i -> i.enabled(true)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().hits();
     }
 
@@ -527,7 +535,12 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
         }
 
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         Aggregate totalAgg = response.aggregations().get("totalAgg");
         Aggregate totalAggregate = totalAgg.nested().aggregations().get("statsBucket");
         long total = totalAggregate.statsBucket().count();
@@ -941,7 +954,12 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
         builder.query(bool);
         builder.size(1000);
         builder.trackTotalHits(TrackHits.of(i -> i.enabled(true)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> idList = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -961,7 +979,12 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
         builder.query(query);
         builder.size(1000);
         builder.trackTotalHits(TrackHits.of(i -> i.enabled(true)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             String id = hit.id();

+ 7 - 1
src/main/java/cn/cslg/pas/service/business/PatentExportService.java

@@ -30,6 +30,7 @@ import cn.cslg.pas.service.business.es.EsPatentService;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.common.MessageService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.aggregations.Aggregate;
 import co.elastic.clients.elasticsearch.core.SearchRequest;
 import co.elastic.clients.elasticsearch.core.SearchResponse;
@@ -335,7 +336,12 @@ public class PatentExportService {
         List<Patent> patentList = new ArrayList<>();
         Records records = new Records();
         SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         Long total = 0L;
         if (org.apache.commons.lang3.StringUtils.isNotEmpty(esPatentCommonVO.getEsField())) {

+ 45 - 7
src/main/java/cn/cslg/pas/service/business/es/EsCountService.java

@@ -14,11 +14,14 @@ import cn.cslg.pas.common.vo.business.EsAllCountVO;
 import cn.cslg.pas.common.vo.business.EsCountVO;
 import cn.cslg.pas.common.vo.es.EsDateRangeVO;
 import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.exception.ExceptionEnum;
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory.EsCountAnalysisBuilderFactory;
 import cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory.IEsCountAnalysisBuilder;
 import cn.cslg.pas.service.business.CommonService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.SortOptions;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.aggregations.*;
@@ -174,7 +177,12 @@ public class EsCountService {
                 builder.aggregations("Agg", aggregation);
                 //解除最大条数限制
                 builder.trackTotalHits(i -> i.enabled(true));
-                SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+                SearchResponse<Patent> response = null;
+                try {
+                    response = client.search(builder.build(), Patent.class);
+                } catch (Exception e) {
+                    throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+                }
                 Aggregate agg = response.aggregations().get("Agg");
 
                 if (StringUtils.isNotEmpty(field)) {
@@ -288,7 +296,12 @@ public class EsCountService {
 
             builder.aggregations("minAgg", filtersAgg);
             builder.aggregations("maxAgg", maxFilters);
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             Aggregate minAgg = response.aggregations().get("minAgg");
             if (minAgg != null) {
                 List<FiltersBucket> list = minAgg.filters().buckets().array();
@@ -795,7 +808,12 @@ public class EsCountService {
         }
         builder.from(pageNum).size(pageSize);
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         return hits.stream().map(Hit::id).collect(Collectors.toList());
     }
@@ -806,7 +824,12 @@ public class EsCountService {
         //设置查询索引
         builder.index("patent");
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         final long childCount = this.ifExistChild1(projectId, fieldId,query);
         return total - childCount;
@@ -829,7 +852,12 @@ public class EsCountService {
         } else {
             builder.query(childQ);
         }
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().total().value();
     }
 
@@ -846,7 +874,12 @@ public class EsCountService {
         builder.query(q);
         builder.from(pageNum).size(pageSize);
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -885,7 +918,12 @@ public class EsCountService {
         builder.query(bool);
         builder.from(0).size(10000);
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> collect = hits.stream().map(Hit::routing).collect(Collectors.toList());
         long total = response.hits().total().value();

+ 63 - 10
src/main/java/cn/cslg/pas/service/business/es/EsCustomFieldService.java

@@ -11,11 +11,13 @@ import cn.cslg.pas.domain.business.CustomField;
 import cn.cslg.pas.domain.business.CustomOption;
 import cn.cslg.pas.domain.business.TreeNode;
 import cn.cslg.pas.domain.es.*;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.business.CustomOptionService;
 import cn.cslg.pas.service.business.TreeNodeService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.aggregations.*;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
@@ -34,6 +36,7 @@ import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.io.IOException;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -338,7 +341,12 @@ public class EsCustomFieldService {
         if (startNum > 0 && number > 0) {
             builder.from(startNum - 1).size(number);
         }
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<String> patentNos = new ArrayList<>();
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
@@ -404,7 +412,12 @@ public class EsCustomFieldService {
         builder.sort(sortOptionsBuilder -> sortOptionsBuilder
                 .field(fieldSortBuilder -> fieldSortBuilder
                         .field("custom_field.create_time").order(SortOrder.Desc)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             List<Hit<Patent>> hits = response.hits().hits();
@@ -464,7 +477,12 @@ public class EsCustomFieldService {
 
         SearchRequest.Builder builder = new SearchRequest.Builder();
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             id = response.hits().hits().get(0).id();
@@ -514,7 +532,12 @@ public class EsCustomFieldService {
         builder.index("patent");
         Query q = QueryBuilders.ids(i -> i.values(Arrays.asList(customFieldId)));
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             patent = response.hits().hits().get(0).source();
@@ -607,7 +630,12 @@ public class EsCustomFieldService {
 
 
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             List<Hit<Patent>> hits = response.hits().hits();
@@ -630,7 +658,12 @@ public class EsCustomFieldService {
         Query q2 = QueryBuilders.parentId(parent -> parent.type("patent").id(patentId));
         Query bool = QueryBuilders.bool(i -> i.must(q1, q2));
         try {
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             List<Hit<Patent>> hits = response.hits().hits();
             hits.forEach(item -> {
             });
@@ -673,7 +706,12 @@ public class EsCustomFieldService {
 
             builder.size(999);
             builder.query(queries);
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             long total = response.hits().total().value();
             List<ESCustomField> esCustomFields = new ArrayList<>();
             List<InnerPatentFieldsVO> innerPatentFieldsVOS = new ArrayList<>();
@@ -830,7 +868,12 @@ public class EsCustomFieldService {
             builder.from(0).size(10000);
         }
         try {
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             long total = response.hits().total().value();
             customFiledRecord.setTotal(total);
             if (total > 0) {
@@ -861,7 +904,12 @@ public class EsCustomFieldService {
                 .field(fieldSortBuilder -> fieldSortBuilder
                         .field("custom_field.create_time").order(SortOrder.Desc)));
         try {
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             long total = response.hits().total().value();
             if (total > 0) {
                 List<Hit<Patent>> hits = response.hits().hits();
@@ -925,7 +973,12 @@ public class EsCustomFieldService {
         builder.sort(sortOptionsBuilder -> sortOptionsBuilder
                 .field(fieldSortBuilder -> fieldSortBuilder
                         .field("custom_field.create_time").order(SortOrder.Desc)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             List<Hit<Patent>> hits = response.hits().hits();

+ 14 - 2
src/main/java/cn/cslg/pas/service/business/es/EsExportService.java

@@ -18,12 +18,14 @@ import cn.cslg.pas.domain.es.ESCustomField;
 import cn.cslg.pas.domain.es.EsProjectTask;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentJoin;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.business.ImportTaskService;
 import cn.cslg.pas.service.common.PatentStarApiService;
 import cn.cslg.pas.service.importPatent.ImportSinglePatentService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.SortOptions;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
@@ -1212,7 +1214,12 @@ public class EsExportService {
             builder.index("patent");
             Query query = QueryBuilders.term(t -> t.field("patent_no.keyword").value(oldPatentNo));
             builder.query(query);
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             List<Hit<Patent>> hits = response.hits().hits();
             if (!CollectionUtils.isEmpty(hits)) {
                 patentId = hits.get(0).id();
@@ -1228,7 +1235,12 @@ public class EsExportService {
         builder.index("patent");
         Query query = QueryBuilders.term(t -> t.field("patent_no.keyword").value(newPatentNo));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
         String newPatentId = "";

+ 79 - 13
src/main/java/cn/cslg/pas/service/business/es/EsPatentService.java

@@ -37,6 +37,7 @@ import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.SortOptions;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.aggregations.Aggregate;
@@ -108,7 +109,12 @@ public class EsPatentService {
         Query q3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(vo.getPatentNo()));
         Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             Patent esMess = hit.source();
@@ -199,7 +205,12 @@ public class EsPatentService {
         Query query = QueryBuilders.hasParent(i -> i.parentType("patent").query(ids));
         Query q = QueryBuilders.bool(i -> i.must(nested, query));
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (IOException e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<PatentMergePerson> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -228,7 +239,12 @@ public class EsPatentService {
         Query query = QueryBuilders.hasParent(i -> i.parentType("patent").query(ids));
         Query q = QueryBuilders.bool(i -> i.must(nested, query));
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (IOException e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<PatentMergePerson> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -257,7 +273,12 @@ public class EsPatentService {
         Query query = QueryBuilders.hasParent(i -> i.parentType("patent").query(ids));
         Query q = QueryBuilders.bool(i -> i.must(nested, query));
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (IOException e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<PatentMergePerson> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -453,7 +474,12 @@ public class EsPatentService {
 //        if (pageNum > 0 && pageSize > 0) {
 //            builder.from((pageNum - 1) * pageSize).size(pageSize);
 //        }
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             PatentKinDTO kinDTO = new PatentKinDTO();
@@ -503,7 +529,12 @@ public class EsPatentService {
         Query bool1 = QueryBuilders.bool(i -> i.must(q, query));
         builder.query(bool1);
 
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             Patent patent = hit.source();
@@ -554,7 +585,12 @@ public class EsPatentService {
         } else {
             builder.from(0).size(10000);
         }
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         if (hits != null && hits.size() > 0) {
             hits.forEach(item -> {
@@ -601,7 +637,12 @@ public class EsPatentService {
         esPatentCommonVO.setSize(null);
         SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
         Records records = new Records();
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             PatentPageMessageVO patentPageMessageVO = new PatentPageMessageVO();
@@ -655,7 +696,12 @@ public class EsPatentService {
                 .filter(fieldSourceBuilder -> fieldSourceBuilder
                         .includes(reSources)));
 
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             if (hits != null && hits.size() > 0) {
@@ -679,7 +725,12 @@ public class EsPatentService {
         builder.source(sourceOptionsBuilder -> sourceOptionsBuilder
                 .filter(fieldSourceBuilder -> fieldSourceBuilder
                         .includes(reSources)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().total().value();
     }
 
@@ -797,7 +848,12 @@ public class EsPatentService {
         builder.index("patent");
         Query q = QueryBuilders.ids(i -> i.values(ids));
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             patents = response.hits().hits();
@@ -820,7 +876,12 @@ public class EsPatentService {
         esPatentCommonVO.setStartNum(startNum);
         esPatentCommonVO.setEndNum(endNum);
         SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             if ((patentNos == null || patentNos.size() == 0) || (!patentNos.contains(hit.source().getPatentNo()))) {
@@ -865,7 +926,12 @@ public class EsPatentService {
         FieldCollapse collapse = FieldCollapse.of(i -> i.field("project_id"));
         builder.collapse(collapse);
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         if (hits != null && hits.size() > 0) {
             hits.forEach(item -> {

+ 9 - 1
src/main/java/cn/cslg/pas/service/business/es/EsPatentVectorService.java

@@ -7,8 +7,11 @@ import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentJoin;
 import cn.cslg.pas.domain.es.Text;
+import cn.cslg.pas.exception.ExceptionEnum;
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.common.PythonApiService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
 import co.elastic.clients.elasticsearch.core.SearchRequest;
@@ -56,7 +59,12 @@ public class EsPatentVectorService {
         Query q2 = QueryBuilders.parentId(parent -> parent.type("patent_vector").id(parentId));
         Query bool = QueryBuilders.bool(i -> i.must(q2));
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             flag = true;

+ 20 - 3
src/main/java/cn/cslg/pas/service/business/es/EsProductPatentService.java

@@ -6,9 +6,11 @@ import cn.cslg.pas.common.vo.PatentWithIdVO;
 import cn.cslg.pas.common.vo.es.EsProductPatentVO;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentJoin;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.InlineScript;
 import co.elastic.clients.elasticsearch._types.Script;
 import co.elastic.clients.elasticsearch._types.query_dsl.IdsQuery;
@@ -82,7 +84,12 @@ public class EsProductPatentService {
                 Query bool1 = QueryBuilders.bool(i -> i.must(q, query));
                 builder.query(bool1);
 
-                SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+                SearchResponse<Patent> response = null;
+                try {
+                    response = client.search(builder.build(), Patent.class);
+                } catch (Exception e) {
+                    throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+                }
                 List<Hit<Patent>> hits = response.hits().hits();
                 for (Hit<Patent> hit : hits) {
                     String id = hit.id();
@@ -119,7 +126,12 @@ public class EsProductPatentService {
         Query q1 = QueryBuilders.term(t -> t.field("product_id").value(productId));
         Query query = QueryBuilders.hasChild(n -> n.type("product").query(q1));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().total().value();
     }
 
@@ -138,7 +150,12 @@ public class EsProductPatentService {
         Query bool = QueryBuilders.bool(i -> i.must(q1,q2));
         Query query = QueryBuilders.hasChild(n -> n.type("product").query(bool));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().total().value();
     }
 

+ 67 - 13
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -122,7 +122,12 @@ public class EsService {
         Query q3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(patentNo));
         Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (IOException e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         if (hits != null && hits.size() > 0) {
             id = hits.get(0).id();
@@ -149,7 +154,12 @@ public class EsService {
         String id = null;
         Query query = QueryBuilders.term(t -> t.field("patent_no.keyword").value(patentNo));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         if (hits != null && hits.size() > 0) {
             id = hits.get(0).id();
@@ -225,8 +235,7 @@ public class EsService {
         try {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
-            e.printStackTrace();
-            throw new XiaoShiException("检索错误,请检查检索式");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
         }
         List<PatentColumnDTO> list = new ArrayList<>();
         List<Hit<Patent>> hits = response.hits().hits();
@@ -363,7 +372,12 @@ public class EsService {
         Query q2 = QueryBuilders.term(i -> i.field(field).value(key));
         Query bool = QueryBuilders.bool(i -> i.must(q1, q2));
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         if (!CollectionUtils.isEmpty(hits)) {
             String id = hits.get(0).id();
@@ -690,7 +704,12 @@ public class EsService {
         optionsList.add(sortOptions);
         builder.sort(optionsList);
 
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         Map<String, ESCustomField> map = new HashMap<>();
         for (Hit<Patent> hit : hits) {
@@ -820,7 +839,12 @@ public class EsService {
 
 
         builder.query(q -> q.hasChild(hasChildQuery.build()));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Patent> list = new ArrayList<>();
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
@@ -848,7 +872,12 @@ public class EsService {
         Query q2 = QueryBuilders.parentId(parent -> parent.type("project").id(parentId));
         Query bool = QueryBuilders.bool(i -> i.must(q1, q2));
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             flag = true;
@@ -874,7 +903,12 @@ public class EsService {
         Query q2 = QueryBuilders.parentId(parent -> parent.type("import_task").id(parentId));
         Query bool = QueryBuilders.bool(i -> i.must(q1, q2, q3));
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             flag = true;
@@ -1271,7 +1305,12 @@ public class EsService {
         Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
         Query bool = QueryBuilders.bool(i -> i.must(q, query));
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         SelectClaimDTO dto = new SelectClaimDTO();
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
@@ -1318,7 +1357,12 @@ public class EsService {
         //申请号
         Query query = QueryBuilders.bool(i -> i.mustNot(queryList));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         SelectClaimDTO dto = new SelectClaimDTO();
         List<Hit<Patent>> hits = response.hits().hits();
         long value = response.hits().total().value();
@@ -1396,7 +1440,12 @@ public class EsService {
         Query q = QueryBuilders.ids(i -> i.values(ids));
         builder.size(9999);
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -1444,7 +1493,12 @@ public class EsService {
         builder.query(bool);
         //解除最大条数限制
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {

+ 8 - 1
src/main/java/cn/cslg/pas/service/business/es/EsValueCurveService.java

@@ -20,6 +20,7 @@ import cn.cslg.pas.domain.business.PermissionRecord;
 import cn.cslg.pas.domain.business.Product;
 import cn.cslg.pas.domain.business.ProductMarketData;
 import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.PermissionRecordMapper;
 import cn.cslg.pas.mapper.ProductMapper;
@@ -27,6 +28,7 @@ import cn.cslg.pas.mapper.ProductMarketDataMapper;
 import cn.cslg.pas.service.business.CommonService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
@@ -346,7 +348,12 @@ public class EsValueCurveService {
                 Query bool1 = QueryBuilders.bool(i -> i.must(q,query));
                 builder.query(bool1);
 
-                SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+                SearchResponse<Patent> response = null;
+                try {
+                    response = client.search(builder.build(), Patent.class);
+                } catch (Exception e) {
+                    throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+                }
                 List<Hit<Patent>> hits = response.hits().hits();
                 for (Hit<Patent> hit : hits) {
                     Patent patent = hit.source();

+ 8 - 1
src/main/java/cn/cslg/pas/service/common/TranslateService.java

@@ -13,8 +13,10 @@ import cn.cslg.pas.domain.es.Content;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentTranslate;
 import cn.cslg.pas.domain.es.Text;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.InlineScript;
 import co.elastic.clients.elasticsearch._types.Refresh;
 import co.elastic.clients.elasticsearch._types.Script;
@@ -101,7 +103,12 @@ public class TranslateService {
         builder.index("patent");
         Query query = QueryBuilders.term(t -> t.field("patent_no.keyword").value(patentNo));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             Patent patent = hit.source();

+ 9 - 1
src/test/java/cn/cslg/pas/service/EventServiceTests.java

@@ -23,6 +23,8 @@ import cn.cslg.pas.controller.PatentController;
 import cn.cslg.pas.domain.es.FamilyPatent;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentFamilyMessage;
+import cn.cslg.pas.exception.ExceptionEnum;
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.AssoProjectEventMapper;
 import cn.cslg.pas.service.business.MergePersonService;
 import cn.cslg.pas.service.business.ProductMarketDataService;
@@ -34,6 +36,7 @@ import cn.cslg.pas.service.common.TranslateService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import cn.hutool.core.util.IdUtil;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch.core.SearchRequest;
 import co.elastic.clients.elasticsearch.core.SearchResponse;
@@ -626,7 +629,12 @@ public class EventServiceTests {
         treeNode tree = expressManager.getInstance().Parse(s, false);
         Query query = formatQueryService.EsQueryToQuery((operateNode) tree, "patent", 331);
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         final List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             System.out.println(1);