Przeglądaj źródła

搜索索引更新2

chao 4 lat temu
rodzic
commit
82691ab981

+ 83 - 37
src/main/java/com/caimei365/commodity/controller/SearchIndexApi.java

@@ -1,9 +1,9 @@
 package com.caimei365.commodity.controller;
 package com.caimei365.commodity.controller;
 
 
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.dto.UpdateIndexDto;
 import com.caimei365.commodity.service.SearchIndexService;
 import com.caimei365.commodity.service.SearchIndexService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -89,120 +89,166 @@ public class SearchIndexApi {
      * 根据商品Id更新
      * 根据商品Id更新
      *
      *
      * spi旧接口:/search/manage/update/product
      * spi旧接口:/search/manage/update/product
-     * @param productId 商品Id
+     *
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      * @return int
      * @return int
      */
      */
     @ApiOperation("根据商品Id更新")
     @ApiOperation("根据商品Id更新")
-    @ApiImplicitParam(required = true, name = "productId", value = "商品Id(旧:pid)")
     @PostMapping("/update/product")
     @PostMapping("/update/product")
-    public ResponseJson<Integer> updateProductIndex(Integer productId){
-        return searchIndexService.updateProductIndexById(productId);
+    public ResponseJson<Integer> updateProductIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.updateProductIndexById(updateIndexDto.getProductId());
     }
     }
 
 
     /**
     /**
      * 根据供应商Id更新
      * 根据供应商Id更新
      *
      *
      * spi旧接口:/search/manage/update/supplier
      * spi旧接口:/search/manage/update/supplier
-     * @param shopId 供应商Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      * @return int
      * @return int
      */
      */
     @ApiOperation("根据供应商Id更新")
     @ApiOperation("根据供应商Id更新")
-    @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id(旧:sid)")
     @PostMapping("/update/shop")
     @PostMapping("/update/shop")
-    public ResponseJson<Integer> updateSupplierIndex(Integer shopId){
-        return searchIndexService.updateSupplierIndexById(shopId);
+    public ResponseJson<Integer> updateSupplierIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.updateSupplierIndexById(updateIndexDto.getShopId());
     }
     }
 
 
     /**
     /**
      * 根据项目仪器Id更新
      * 根据项目仪器Id更新
      *
      *
      * spi旧接口:/search/manage/update/equipment
      * spi旧接口:/search/manage/update/equipment
-     * @param equipmentId 仪器Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      * @return int
      * @return int
      */
      */
     @ApiOperation("根据仪器Id更新")
     @ApiOperation("根据仪器Id更新")
-    @ApiImplicitParam(required = true, name = "equipmentId", value = "仪器Id(旧:eid)")
     @PostMapping("/update/equipment")
     @PostMapping("/update/equipment")
-    public ResponseJson<Integer> updateEquipmentIndex(Integer equipmentId){
-        return searchIndexService.updateEquipmentIndexById(equipmentId);
+    public ResponseJson<Integer> updateEquipmentIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.updateEquipmentIndexById(updateIndexDto.getEquipmentId());
     }
     }
 
 
     /**
     /**
      * 根据文章Id更新
      * 根据文章Id更新
      *
      *
      * spi旧接口:/search/manage/update/article
      * spi旧接口:/search/manage/update/article
-     * @param articleId 文章Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      * @return int
      * @return int
      */
      */
     @ApiOperation("根据文章Id更新")
     @ApiOperation("根据文章Id更新")
-    @ApiImplicitParam(required = true, name = "articleId", value = "文章Id(旧:aid)")
     @PostMapping("/update/article")
     @PostMapping("/update/article")
-    public ResponseJson<Integer> updateArticleIndex(Integer articleId){
-        return searchIndexService.updateArticleIndexById(articleId);
+    public ResponseJson<Integer> updateArticleIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.updateArticleIndexById(updateIndexDto.getArticleId());
     }
     }
 
 
     /**
     /**
      * 根据商品Id删除
      * 根据商品Id删除
      *
      *
      * spi旧接口:/search/manage/delete/product
      * spi旧接口:/search/manage/delete/product
-     * @param productId 商品Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      */
      */
     @ApiOperation("根据商品Id删除")
     @ApiOperation("根据商品Id删除")
-    @ApiImplicitParam(required = true, name = "productId", value = "商品Id(旧:pid)")
     @PostMapping("/delete/product")
     @PostMapping("/delete/product")
-    public ResponseJson<Integer> deleteProductIndex(Integer productId){
-        return searchIndexService.deleteProductIndexById(productId);
+    public ResponseJson<Integer> deleteProductIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.deleteProductIndexById(updateIndexDto.getProductId());
     }
     }
 
 
     /**
     /**
      * 根据供应商Id删除
      * 根据供应商Id删除
      *
      *
      * spi旧接口:/search/manage/delete/supplier
      * spi旧接口:/search/manage/delete/supplier
-     * @param shopId 供应商Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      */
      */
     @ApiOperation("根据供应商Id删除")
     @ApiOperation("根据供应商Id删除")
-    @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id(旧:sid)")
     @PostMapping("/delete/shop")
     @PostMapping("/delete/shop")
-    public ResponseJson<Integer> deleteSupplierIndex(Integer shopId){
-        return searchIndexService.deleteSupplierIndexById(shopId);
+    public ResponseJson<Integer> deleteSupplierIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.deleteSupplierIndexById(updateIndexDto.getShopId());
     }
     }
 
 
     /**
     /**
      * 根据项目仪器Id删除
      * 根据项目仪器Id删除
      *
      *
      * spi旧接口:/search/manage/delete/equipment
      * spi旧接口:/search/manage/delete/equipment
-     * @param equipmentId 仪器Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      */
      */
     @ApiOperation("根据项目仪器Id删除")
     @ApiOperation("根据项目仪器Id删除")
-    @ApiImplicitParam(required = true, name = "equipmentId", value = "仪器Id(旧:eid)")
     @PostMapping("/delete/equipment")
     @PostMapping("/delete/equipment")
-    public ResponseJson<Integer> deleteEquipmentIndex(Integer equipmentId){
-        return searchIndexService.deleteEquipmentIndexById(equipmentId);
+    public ResponseJson<Integer> deleteEquipmentIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.deleteEquipmentIndexById(updateIndexDto.getEquipmentId());
     }
     }
 
 
     /**
     /**
      * 根据文章Id删除
      * 根据文章Id删除
      *
      *
      * spi旧接口:/search/manage/delete/article
      * spi旧接口:/search/manage/delete/article
-     * @param articleId 文章Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      */
      */
     @ApiOperation("根据文章Id删除")
     @ApiOperation("根据文章Id删除")
-    @ApiImplicitParam(required = true, name = "articleId", value = "文章Id(旧:aid)")
     @PostMapping("/delete/article")
     @PostMapping("/delete/article")
-    public ResponseJson<Integer> deleteArticleIndex(Integer articleId){
-        return searchIndexService.deleteArticleIndexById(articleId);
+    public ResponseJson<Integer> deleteArticleIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.deleteArticleIndexById(updateIndexDto.getArticleId());
     }
     }
 
 
     /**
     /**
      * 根据主文档Id删除
      * 根据主文档Id删除
      *
      *
      * spi旧接口:/search/manage/delete/main
      * spi旧接口:/search/manage/delete/main
-     * @param id 文档Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      */
      */
     @ApiOperation("根据主文档Id删除")
     @ApiOperation("根据主文档Id删除")
-    @ApiImplicitParam(required = true, name = "id", value = "文档Id")
     @PostMapping("/delete/main")
     @PostMapping("/delete/main")
-    public ResponseJson<Integer> deleteMainIndex(Integer id){
-        return searchIndexService.deleteMainIndexById(id);
+    public ResponseJson<Integer> deleteMainIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.deleteMainIndexById(updateIndexDto.getId());
     }
     }
 }
 }

+ 42 - 0
src/main/java/com/caimei365/commodity/model/dto/UpdateIndexDto.java

@@ -0,0 +1,42 @@
+package com.caimei365.commodity.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/5/26
+ */
+@Data
+public class UpdateIndexDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 主键id
+     */
+    @ApiModelProperty("主键id")
+    private Integer id;
+    /**
+     * 商品id
+     */
+    @ApiModelProperty("商品id")
+    private Integer productId;
+    /**
+     * 供应商id
+     */
+    @ApiModelProperty("供应商id")
+    private Integer shopId;
+    /**
+     * 项目仪器id
+     */
+    @ApiModelProperty("项目仪器id")
+    private Integer equipmentId;
+    /**
+     * 文章id
+     */
+    @ApiModelProperty("文章id")
+    private Integer articleId;
+}

+ 84 - 67
src/main/java/com/caimei365/commodity/service/impl/SearchIndexServiceImpl.java

@@ -201,12 +201,12 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         if (null != product) {
         if (null != product) {
             // 定义星范商品数据
             // 定义星范商品数据
             List<DocumentDTO<MallProductDO>> mallProductList = new ArrayList<>();
             List<DocumentDTO<MallProductDO>> mallProductList = new ArrayList<>();
-            // 星范商品设值,【必须先于商品文档设值】
-            Integer mallId = setMallProductDocument(mallProductList, productId);
+//            // 星范商品设值,【必须先于商品文档设值】
+//            Integer mallId = setMallProductDocument(mallProductList, productId);
             // 定义商品文档数据
             // 定义商品文档数据
             List<DocumentDTO<ProductDO>> productList = new ArrayList<>();
             List<DocumentDTO<ProductDO>> productList = new ArrayList<>();
             // 商品文档设值
             // 商品文档设值
-            setProductDocument(productList, product, mallId);
+            setProductDocument(productList, product, null);
             // 定义主文档入口数据
             // 定义主文档入口数据
             List<DocumentDTO<MainDO>> mainList = new ArrayList<>();
             List<DocumentDTO<MainDO>> mainList = new ArrayList<>();
             // 主文档设值
             // 主文档设值
@@ -214,21 +214,17 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             if (mainId == -1) {
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = mainId == -1 ? 0 : mainId+1;
                 mainId = mainId == -1 ? 0 : mainId+1;
+                //  新增主文档, 商品:type=1
+                setMainDocument(1, mainList, mainId, productId);
             }
             }
-            // 商品文档 type=1
-            setMainDocument(1, mainList, mainId, productId);
             try {
             try {
                 // 查询商品数量是否唯一,不唯一则删除后更新索引
                 // 查询商品数量是否唯一,不唯一则删除后更新索引
                 Integer count = searchQueryService.getCountByDocId("product", productId);
                 Integer count = searchQueryService.getCountByDocId("product", productId);
                 if (count > 1) {
                 if (count > 1) {
-                    log.info("商品重复,重复商品id>>>>>>>>>>>" + productId);
-                    if (mainId > 0) {
-                        // 删除主文档记录
-                        deleteDocByTypeId("id", mainId, "search_main");
-                        return updateProductIndexById(productId);
-                    }
-                    // 主文档不存在,删除商品文档
-                    return deleteProductIndexById(productId);
+                    log.info("商品重复,重复商品>>>>>>>>>>>" + productId +"重复数量:" + count);
+                    // 删除主文档记录
+                    deleteDocByTypeId("id", mainId, "search_main");
+                    return updateProductIndexById(productId);
                 } else {
                 } else {
                     // 推送到阿里云
                     // 推送到阿里云
                     pushProductDocument(mainList, productList, mallProductList);
                     pushProductDocument(mainList, productList, mallProductList);
@@ -269,21 +265,17 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             if (mainId == -1) {
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = mainId == -1 ? 0 : mainId+1;
                 mainId = mainId == -1 ? 0 : mainId+1;
+                //  新增主文档, 供应商:type=2
+                setMainDocument(2, mainList, mainId, shopId);
             }
             }
-            // 供应商文档 type=2
-            setMainDocument(2, mainList, mainId, shopId);
             try {
             try {
                 // 查询供应商是否唯一,不唯一则删除后重新更新索引
                 // 查询供应商是否唯一,不唯一则删除后重新更新索引
                 Integer count = searchQueryService.getCountByDocId("shop", shopId);
                 Integer count = searchQueryService.getCountByDocId("shop", shopId);
                 if (count > 1) {
                 if (count > 1) {
-                    log.info("供应商重复,重复供应商id>>>>>>>>>>>" + shopId);
-                    if (mainId > 0) {
-                        // 删除主文档记录
-                        deleteDocByTypeId("id", mainId, "search_main");
-                        return updateSupplierIndexById(shopId);
-                    }
-                    // 主文档不存在,删除供应商文档
-                    return deleteSupplierIndexById(shopId);
+                    log.info("供应商重复,重复供应商>>>>>>>>>>>" + shopId +"重复数量:" + count);;
+                    // 删除主文档记录
+                    deleteDocByTypeId("id", mainId, "search_main");
+                    return updateSupplierIndexById(shopId);
                 } else {
                 } else {
                     // 将文档列表转换成Json串,并推送到阿里云
                     // 将文档列表转换成Json串,并推送到阿里云
                     pushSupplierDocument(mainList, supplierList);
                     pushSupplierDocument(mainList, supplierList);
@@ -324,21 +316,17 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             if (mainId == -1) {
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = mainId == -1 ? 0 : mainId+1;
                 mainId = mainId == -1 ? 0 : mainId+1;
+                // 新增主文档, 项目仪器:type=3
+                setMainDocument(3, mainList, mainId, equipmentId);
             }
             }
-            // 项目仪器文档 type=3
-            setMainDocument(3, mainList, mainId, equipmentId);
             try {
             try {
                 // 查询项目仪器数量是否唯一,不唯一则删除后重新更新索引
                 // 查询项目仪器数量是否唯一,不唯一则删除后重新更新索引
                 Integer count = searchQueryService.getCountByDocId("equipment", equipmentId);
                 Integer count = searchQueryService.getCountByDocId("equipment", equipmentId);
                 if (count > 1) {
                 if (count > 1) {
-                    log.info("项目仪器重复,重复项目仪器id>>>>>>>>>>>" + equipmentId);
-                    if (mainId > 0) {
-                        // 删除主文档记录
-                        deleteDocByTypeId("id", mainId, "search_main");
-                        return updateEquipmentIndexById(equipmentId);
-                    }
-                    // 主文档不存在,删除项目仪器文档
-                    return deleteEquipmentIndexById(equipmentId);
+                    log.info("项目仪器重复,重复项目仪器>>>>>>>>>>>" + equipmentId+"重复数量:" + count);
+                    // 删除主文档记录
+                    deleteDocByTypeId("id", mainId, "search_main");
+                    return updateEquipmentIndexById(equipmentId);
                 } else {
                 } else {
                     // 将文档列表转换成Json串,并推送到阿里云
                     // 将文档列表转换成Json串,并推送到阿里云
                     pushEquipmentDocument(mainList, equipmentList);
                     pushEquipmentDocument(mainList, equipmentList);
@@ -379,26 +367,23 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             if (mainId == -1) {
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = mainId == -1 ? 0 : mainId+1;
                 mainId = mainId == -1 ? 0 : mainId+1;
+                // 新增主文档, 文章 type=4
+                setMainDocument(4, mainList, mainId, articleId);
             }
             }
-            // 文章文档 type=4
-            setMainDocument(4, mainList, mainId, articleId);
+
             try {
             try {
                 // 查询文章数量是否唯一,不唯一则删除后重新更新索引
                 // 查询文章数量是否唯一,不唯一则删除后重新更新索引
                 Integer count = searchQueryService.getCountByDocId("article", articleId);
                 Integer count = searchQueryService.getCountByDocId("article", articleId);
                 if (count > 1) {
                 if (count > 1) {
-                    log.info("文章重复,重复文章id>>>>>>>>>>>" + articleId);
-                    if (mainId > 0) {
-                        // 删除主文档记录
-                        deleteDocByTypeId("id", mainId, "search_main");
-                        return updateArticleIndexById(articleId);
-                    }
-                    // 主文档不存在,删除文章文档
-                    return deleteArticleIndexById(articleId);
+                    log.info("文章重复,重复文章>>>>>>>>>>>" + articleId +"重复数量:" + count);
+                    // 删除主文档记录
+                    deleteDocByTypeId("id", mainId, "search_main");
+                    return updateArticleIndexById(articleId);
                 } else {
                 } else {
                     // 将主文档列表转换成Json串,并推送到阿里云
                     // 将主文档列表转换成Json串,并推送到阿里云
                     pushArticleDocument(mainList, articleList);
                     pushArticleDocument(mainList, articleList);
                     // 返回结果
                     // 返回结果
-                    return ResponseJson.success(mainList.size());
+                    return ResponseJson.success(articleList.size());
                 }
                 }
             } catch (OpenSearchClientException | OpenSearchException | JSONException e) {
             } catch (OpenSearchClientException | OpenSearchException | JSONException e) {
                 log.error("添加文章文档异常:" + e);
                 log.error("添加文章文档异常:" + e);
@@ -615,10 +600,10 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
 
             int productMainId;
             int productMainId;
             for (ProductDO product : dbList) {
             for (ProductDO product : dbList) {
-                // 星范商品设值,【必须先于商品文档设值】
-                Integer mallId = setMallProductDocument(mallProductList, product.getP_id());
+//                // 星范商品设值,【必须先于商品文档设值】
+//                Integer mallId = setMallProductDocument(mallProductList, product.getP_id());
                 // 商品文档设值
                 // 商品文档设值
-                setProductDocument(productList, product, mallId);
+                setProductDocument(productList, product, null);
                 // 主文档设值
                 // 主文档设值
                 Integer productId = product.getP_id();
                 Integer productId = product.getP_id();
                 if(initFlag){
                 if(initFlag){
@@ -661,14 +646,22 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * @throws OpenSearchException exp
      * @throws OpenSearchException exp
      */
      */
     private void pushProductDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<ProductDO>> productList, List<DocumentDTO<MallProductDO>> mallProductList) throws OpenSearchClientException, OpenSearchException {
     private void pushProductDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<ProductDO>> productList, List<DocumentDTO<MallProductDO>> mallProductList) throws OpenSearchClientException, OpenSearchException {
-        // 将主文档列表转换成Json串,并推送到阿里云
-        String mainDocStr = new JSONArray(mainList).toString();
-        String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "):" + mainResult + "】" + mainList.toString());
+        if (mainList.size()>0) {
+            // 将主文档列表转换成Json串,并推送到阿里云
+            String mainDocStr = new JSONArray(mainList).toString();
+            String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
+            log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "个):" + mainResult + "】" + mainList.toString());
+        }
         // 将商品文档推送到阿里云
         // 将商品文档推送到阿里云
         String productDocStr = new JSONArray(productList).toString();
         String productDocStr = new JSONArray(productList).toString();
         String productResult = searchOpenService.pushDocument(productDocStr, "search_product");
         String productResult = searchOpenService.pushDocument(productDocStr, "search_product");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_product(" + productList.size() + "):" + productResult + "】");
+        if (mainList.size()>0) {
+            // 新增
+            log.info(">>>>>>>>>>>>>>>add document: 【search_product(" + productList.size() + "个):" + productResult + "】");
+        } else {
+            // 更新
+            log.info(">>>>>>>>>>>>>>>update document: 【search_product(" + productList.size() + "个):" + productResult + "】");
+        }
         // 将星范商品推送到阿里云
         // 将星范商品推送到阿里云
         if (mallProductList.size()>0) {
         if (mallProductList.size()>0) {
             String mallProductStr = new JSONArray(mallProductList).toString();
             String mallProductStr = new JSONArray(mallProductList).toString();
@@ -785,14 +778,22 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * @throws OpenSearchException exp
      * @throws OpenSearchException exp
      */
      */
     private void pushSupplierDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<SupplierDO>> supplierList) throws OpenSearchClientException, OpenSearchException {
     private void pushSupplierDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<SupplierDO>> supplierList) throws OpenSearchClientException, OpenSearchException {
-        // 将主文档列表转换成Json串,并推送到阿里云
-        String mainDocStr = new JSONArray(mainList).toString();
-        String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "):" + mainResult + "】" + mainList.toString());
+        if (mainList.size()>0) {
+            // 将主文档列表转换成Json串,并推送到阿里云
+            String mainDocStr = new JSONArray(mainList).toString();
+            String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
+            log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "个):" + mainResult + "】" + mainList.toString());
+        }
         // 将商品文档推送到阿里云
         // 将商品文档推送到阿里云
         String supplierDocStr = new JSONArray(supplierList).toString();
         String supplierDocStr = new JSONArray(supplierList).toString();
         String supplierResult = searchOpenService.pushDocument(supplierDocStr, "search_supplier");
         String supplierResult = searchOpenService.pushDocument(supplierDocStr, "search_supplier");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_supplier(" + supplierList.size() + "):" + supplierResult + "】");
+        if (mainList.size()>0) {
+            // 新增
+            log.info(">>>>>>>>>>>>>>>add document: 【search_supplier(" + supplierList.size() + "个):" + supplierResult + "】");
+        } else {
+            // 更新
+            log.info(">>>>>>>>>>>>>>>update document: 【search_supplier(" + supplierList.size() + "个):" + supplierResult + "】");
+        }
     }
     }
 
 
     /**
     /**
@@ -903,14 +904,22 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * @throws OpenSearchException exp
      * @throws OpenSearchException exp
      */
      */
     private void pushEquipmentDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<EquipmentDO>> equipmentList) throws OpenSearchClientException, OpenSearchException {
     private void pushEquipmentDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<EquipmentDO>> equipmentList) throws OpenSearchClientException, OpenSearchException {
-        // 将主文档列表转换成Json串,并推送到阿里云
-        String mainDocStr = new JSONArray(mainList).toString();
-        String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "):" + mainResult + "】" + mainList.toString());
+        if (mainList.size()>0) {
+            // 将主文档列表转换成Json串,并推送到阿里云
+            String mainDocStr = new JSONArray(mainList).toString();
+            String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
+            log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "个):" + mainResult + "】" + mainList.toString());
+        }
         // 将商品文档推送到阿里云
         // 将商品文档推送到阿里云
         String equipmentDocStr = new JSONArray(equipmentList).toString();
         String equipmentDocStr = new JSONArray(equipmentList).toString();
         String equipmentResult = searchOpenService.pushDocument(equipmentDocStr, "search_equipment");
         String equipmentResult = searchOpenService.pushDocument(equipmentDocStr, "search_equipment");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_equipment(" + equipmentList.size() + "):" + equipmentResult + "】");
+        if (mainList.size()>0) {
+            // 新增
+            log.info(">>>>>>>>>>>>>>>add document: 【search_equipment(" + equipmentList.size() + "个):" + equipmentResult + "】");
+        } else {
+            // 更新
+            log.info(">>>>>>>>>>>>>>>update document: 【search_equipment(" + equipmentList.size() + "个):" + equipmentResult + "】");
+        }
     }
     }
 
 
     /**
     /**
@@ -1021,14 +1030,22 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * @throws OpenSearchException exp
      * @throws OpenSearchException exp
      */
      */
     private void pushArticleDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<ArticleDO>> articleList) throws OpenSearchClientException, OpenSearchException {
     private void pushArticleDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<ArticleDO>> articleList) throws OpenSearchClientException, OpenSearchException {
-        // 将主文档列表转换成Json串,并推送到阿里云
-        String mainDocStr = new JSONArray(mainList).toString();
-        String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "):" + mainResult + "】" + mainList.toString());
+        if (mainList.size()>0) {
+            // 将主文档列表转换成Json串,并推送到阿里云
+            String mainDocStr = new JSONArray(mainList).toString();
+            String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
+            log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "个):" + mainResult + "】" + mainList.toString());
+        }
         // 将商品文档推送到阿里云
         // 将商品文档推送到阿里云
         String articleDocStr = new JSONArray(articleList).toString();
         String articleDocStr = new JSONArray(articleList).toString();
         String articleResult = searchOpenService.pushDocument(articleDocStr, "search_article");
         String articleResult = searchOpenService.pushDocument(articleDocStr, "search_article");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_article(" + articleList.size() + "):" + articleResult + "】");
+        if (mainList.size()>0) {
+            // 新增
+            log.info(">>>>>>>>>>>>>>>add document: 【search_article(" + articleList.size() + "个):" + articleResult + "】");
+        } else {
+            // 更新
+            log.info(">>>>>>>>>>>>>>>update document: 【search_article(" + articleList.size() + "个):" + articleResult + "】");
+        }
     }
     }
 
 
     /**
     /**