|
@@ -214,6 +214,12 @@ public class SearchIndexServiceImpl implements SearchIndexService {
|
|
// 商品文档 type=1
|
|
// 商品文档 type=1
|
|
setMainDocument(1, mainList, mainId, productId);
|
|
setMainDocument(1, mainList, mainId, productId);
|
|
try {
|
|
try {
|
|
|
|
+ // 查询商品数量是否唯一,不唯一则删除后更新索引
|
|
|
|
+ Integer count = searchQueryService.getCountByDocId("product", productId);
|
|
|
|
+ if (count > 1) {
|
|
|
|
+ log.info("商品重复,重复商品id>>>>>>>>>>>" + productId);
|
|
|
|
+ deleteProductIndexById(productId);
|
|
|
|
+ }
|
|
// 推送到阿里云
|
|
// 推送到阿里云
|
|
pushProductDocument(mainList, productList, mallProductList);
|
|
pushProductDocument(mainList, productList, mallProductList);
|
|
// 返回结果
|
|
// 返回结果
|
|
@@ -252,6 +258,12 @@ public class SearchIndexServiceImpl implements SearchIndexService {
|
|
// 供应商文档 type=2
|
|
// 供应商文档 type=2
|
|
setMainDocument(2, mainList, mainId, shopId);
|
|
setMainDocument(2, mainList, mainId, shopId);
|
|
try {
|
|
try {
|
|
|
|
+ // 查询供应商是否唯一,不唯一则删除后重新更新索引
|
|
|
|
+ Integer count = searchQueryService.getCountByDocId("shop", shopId);
|
|
|
|
+ if (count > 1) {
|
|
|
|
+ log.info("供应商重复,重复供应商id>>>>>>>>>>>" + shopId);
|
|
|
|
+ deleteSupplierIndexById(shopId);
|
|
|
|
+ }
|
|
// 将文档列表转换成Json串,并推送到阿里云
|
|
// 将文档列表转换成Json串,并推送到阿里云
|
|
pushSupplierDocument(mainList, supplierList);
|
|
pushSupplierDocument(mainList, supplierList);
|
|
// 返回结果
|
|
// 返回结果
|
|
@@ -290,6 +302,12 @@ public class SearchIndexServiceImpl implements SearchIndexService {
|
|
// 项目仪器文档 type=3
|
|
// 项目仪器文档 type=3
|
|
setMainDocument(3, mainList, mainId, equipmentId);
|
|
setMainDocument(3, mainList, mainId, equipmentId);
|
|
try {
|
|
try {
|
|
|
|
+ // 查询项目仪器数量是否唯一,不唯一则删除后重新更新索引
|
|
|
|
+ Integer count = searchQueryService.getCountByDocId("equipment", equipmentId);
|
|
|
|
+ if (count > 1) {
|
|
|
|
+ log.info("项目仪器重复,重复项目仪器id>>>>>>>>>>>" + equipmentId);
|
|
|
|
+ deleteEquipmentIndexById(equipmentId);
|
|
|
|
+ }
|
|
// 将文档列表转换成Json串,并推送到阿里云
|
|
// 将文档列表转换成Json串,并推送到阿里云
|
|
pushEquipmentDocument(mainList, equipmentList);
|
|
pushEquipmentDocument(mainList, equipmentList);
|
|
// 返回结果
|
|
// 返回结果
|
|
@@ -328,15 +346,14 @@ public class SearchIndexServiceImpl implements SearchIndexService {
|
|
// 文章文档 type=4
|
|
// 文章文档 type=4
|
|
setMainDocument(4, mainList, mainId, articleId);
|
|
setMainDocument(4, mainList, mainId, articleId);
|
|
try {
|
|
try {
|
|
- // 将主文档列表转换成Json串,并推送到阿里云
|
|
|
|
- pushArticleDocument(mainList, articleList);
|
|
|
|
// 查询文章数量是否唯一,不唯一则删除后重新更新索引
|
|
// 查询文章数量是否唯一,不唯一则删除后重新更新索引
|
|
Integer count = searchQueryService.getCountByDocId("article", articleId);
|
|
Integer count = searchQueryService.getCountByDocId("article", articleId);
|
|
if (count > 1) {
|
|
if (count > 1) {
|
|
log.info("文章重复,重复文章id>>>>>>>>>>>" + articleId);
|
|
log.info("文章重复,重复文章id>>>>>>>>>>>" + articleId);
|
|
deleteArticleIndexById(articleId);
|
|
deleteArticleIndexById(articleId);
|
|
- updateArticleIndexById(articleId);
|
|
|
|
}
|
|
}
|
|
|
|
+ // 将主文档列表转换成Json串,并推送到阿里云
|
|
|
|
+ pushArticleDocument(mainList, articleList);
|
|
// 返回结果
|
|
// 返回结果
|
|
return ResponseJson.success(mainList.size());
|
|
return ResponseJson.success(mainList.size());
|
|
} catch (OpenSearchClientException | OpenSearchException | JSONException e) {
|
|
} catch (OpenSearchClientException | OpenSearchException | JSONException e) {
|
|
@@ -364,6 +381,9 @@ public class SearchIndexServiceImpl implements SearchIndexService {
|
|
deleteDocByTypeId("m_id", mallId, "search_product_mall");
|
|
deleteDocByTypeId("m_id", mallId, "search_product_mall");
|
|
}
|
|
}
|
|
deleteDocByTypeId("p_id", productId, "search_product");
|
|
deleteDocByTypeId("p_id", productId, "search_product");
|
|
|
|
+ // 删除主文档记录
|
|
|
|
+ Integer mainId = searchQueryService.getIdByDocId("product", productId);
|
|
|
|
+ deleteDocByTypeId("id", mainId, "search_main");
|
|
// 返回结果
|
|
// 返回结果
|
|
return ResponseJson.success(1);
|
|
return ResponseJson.success(1);
|
|
} catch (OpenSearchClientException | OpenSearchException | JSONException e) {
|
|
} catch (OpenSearchClientException | OpenSearchException | JSONException e) {
|
|
@@ -382,6 +402,9 @@ public class SearchIndexServiceImpl implements SearchIndexService {
|
|
public ResponseJson<Integer> deleteSupplierIndexById(Integer shopId) {
|
|
public ResponseJson<Integer> deleteSupplierIndexById(Integer shopId) {
|
|
try {
|
|
try {
|
|
deleteDocByTypeId("s_id", shopId, "search_supplier");
|
|
deleteDocByTypeId("s_id", shopId, "search_supplier");
|
|
|
|
+ // 删除主文档记录
|
|
|
|
+ Integer mainId = searchQueryService.getIdByDocId("shop", shopId);
|
|
|
|
+ deleteDocByTypeId("id", mainId, "search_main");
|
|
// 返回结果
|
|
// 返回结果
|
|
return ResponseJson.success(1);
|
|
return ResponseJson.success(1);
|
|
} catch (OpenSearchClientException | OpenSearchException | JSONException e) {
|
|
} catch (OpenSearchClientException | OpenSearchException | JSONException e) {
|
|
@@ -400,6 +423,9 @@ public class SearchIndexServiceImpl implements SearchIndexService {
|
|
public ResponseJson<Integer> deleteEquipmentIndexById(Integer equipmentId) {
|
|
public ResponseJson<Integer> deleteEquipmentIndexById(Integer equipmentId) {
|
|
try {
|
|
try {
|
|
deleteDocByTypeId("e_id", equipmentId, "search_equipment");
|
|
deleteDocByTypeId("e_id", equipmentId, "search_equipment");
|
|
|
|
+ // 删除主文档记录
|
|
|
|
+ Integer mainId = searchQueryService.getIdByDocId("equipment", equipmentId);
|
|
|
|
+ deleteDocByTypeId("id", mainId, "search_main");
|
|
// 返回结果
|
|
// 返回结果
|
|
return ResponseJson.success(1);
|
|
return ResponseJson.success(1);
|
|
} catch (OpenSearchClientException | OpenSearchException | JSONException e) {
|
|
} catch (OpenSearchClientException | OpenSearchException | JSONException e) {
|
|
@@ -417,7 +443,11 @@ public class SearchIndexServiceImpl implements SearchIndexService {
|
|
@Override
|
|
@Override
|
|
public ResponseJson<Integer> deleteArticleIndexById(Integer articleId) {
|
|
public ResponseJson<Integer> deleteArticleIndexById(Integer articleId) {
|
|
try {
|
|
try {
|
|
|
|
+ // 删除文章文档记录
|
|
deleteDocByTypeId("a_id", articleId, "search_article");
|
|
deleteDocByTypeId("a_id", articleId, "search_article");
|
|
|
|
+ // 删除主文档记录
|
|
|
|
+ Integer mainId = searchQueryService.getIdByDocId("article", articleId);
|
|
|
|
+ deleteDocByTypeId("id", mainId, "search_main");
|
|
// 返回结果
|
|
// 返回结果
|
|
return ResponseJson.success(1);
|
|
return ResponseJson.success(1);
|
|
} catch (OpenSearchClientException | OpenSearchException | JSONException e) {
|
|
} catch (OpenSearchClientException | OpenSearchException | JSONException e) {
|