全文检索、标题检索去掉废止状态

This commit is contained in:
梁琦涛
2024-03-20 19:17:21 +08:00
parent f77ac7c3b9
commit 459e468711
@@ -63,16 +63,6 @@ public class HomeSearchCheckEsPlanJob implements Job {
List<String> listType = getList(resourceType); List<String> listType = getList(resourceType);
Map<String,Integer> mapHash = getTypeCount(); Map<String,Integer> mapHash = getTypeCount();
listType.parallelStream().forEach(p->{ listType.parallelStream().forEach(p->{
// 删除数据
JSONObject jsonQuery = new JSONObject();
JSONObject jsonTerm = new JSONObject();
JSONObject jsonField = new JSONObject();
JSONObject jsonValue = new JSONObject();
jsonValue.put("value",p);
jsonField.put("resource_type",jsonValue);
jsonTerm.put("term",jsonField);
jsonQuery.put("query",jsonTerm);
jeroElasticsearchTemplate.delete(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue(), HomeSearchEnum.TYPE_NAME_DOCUMENT_ZQ.getValue(), jsonQuery);
switch (p){ switch (p){
// 比对国内标准 // 比对国内标准
case LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD: case LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD:
@@ -104,6 +94,7 @@ public class HomeSearchCheckEsPlanJob implements Job {
m4 = listLawsNewsFeed.size(); m4 = listLawsNewsFeed.size();
} }
if(count4 != m4 || !StringUtils.isBlank(resourceType)){ if(count4 != m4 || !StringUtils.isBlank(resourceType)){
removeES(LawsHomeSearchCommon.LAWS_NEWS_FEED);
if(!CollectionUtils.isEmpty(listLawsNewsFeed)){ if(!CollectionUtils.isEmpty(listLawsNewsFeed)){
List<String> listIds = listLawsNewsFeed.stream().map(LawsNewsFeed::getId).collect(Collectors.toList()); List<String> listIds = listLawsNewsFeed.stream().map(LawsNewsFeed::getId).collect(Collectors.toList());
addES(listIds, LawsHomeSearchCommon.LAWS_NEWS_FEED); addES(listIds, LawsHomeSearchCommon.LAWS_NEWS_FEED);
@@ -119,6 +110,7 @@ public class HomeSearchCheckEsPlanJob implements Job {
m3 = listLawsEnterpriseStandard.size(); m3 = listLawsEnterpriseStandard.size();
} }
if(count3 != m3 || !StringUtils.isBlank(resourceType)){ if(count3 != m3 || !StringUtils.isBlank(resourceType)){
removeES(LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD);
if(!CollectionUtils.isEmpty(listLawsEnterpriseStandard)){ if(!CollectionUtils.isEmpty(listLawsEnterpriseStandard)){
List<String> listIds = listLawsEnterpriseStandard.stream().map(LawsEnterpriseStandard::getId).collect(Collectors.toList()); List<String> listIds = listLawsEnterpriseStandard.stream().map(LawsEnterpriseStandard::getId).collect(Collectors.toList());
addES(listIds, LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD); addES(listIds, LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD);
@@ -134,6 +126,7 @@ public class HomeSearchCheckEsPlanJob implements Job {
m2 = listLawsOverseasStandard.size(); m2 = listLawsOverseasStandard.size();
} }
if(count2 != m2 || !StringUtils.isBlank(resourceType)){ if(count2 != m2 || !StringUtils.isBlank(resourceType)){
removeES(LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD);
if(!CollectionUtils.isEmpty(listLawsOverseasStandard)){ if(!CollectionUtils.isEmpty(listLawsOverseasStandard)){
List<String> listIds = listLawsOverseasStandard.stream().map(LawsOverseasStandard::getId).collect(Collectors.toList()); List<String> listIds = listLawsOverseasStandard.stream().map(LawsOverseasStandard::getId).collect(Collectors.toList());
addES(listIds, LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD); addES(listIds, LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD);
@@ -150,6 +143,7 @@ public class HomeSearchCheckEsPlanJob implements Job {
m1 = listLawsDomesticStandard.size(); m1 = listLawsDomesticStandard.size();
} }
if(count1 != m1 || !StringUtils.isBlank(resourceType)){ if(count1 != m1 || !StringUtils.isBlank(resourceType)){
removeES(LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD);
if(!CollectionUtils.isEmpty(listLawsDomesticStandard)){ if(!CollectionUtils.isEmpty(listLawsDomesticStandard)){
List<String> listIds = listLawsDomesticStandard.stream().map(LawsDomesticStandard::getId).collect(Collectors.toList()); List<String> listIds = listLawsDomesticStandard.stream().map(LawsDomesticStandard::getId).collect(Collectors.toList());
addES(listIds, LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD); addES(listIds, LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD);
@@ -157,6 +151,19 @@ public class HomeSearchCheckEsPlanJob implements Job {
} }
} }
private void removeES(String type){
// 删除数据
JSONObject jsonQuery = new JSONObject();
JSONObject jsonTerm = new JSONObject();
JSONObject jsonField = new JSONObject();
JSONObject jsonValue = new JSONObject();
jsonValue.put("value",type);
jsonField.put("resource_type",jsonValue);
jsonTerm.put("term",jsonField);
jsonQuery.put("query",jsonTerm);
jeroElasticsearchTemplate.delete(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue(), HomeSearchEnum.TYPE_NAME_DOCUMENT_ZQ.getValue(), jsonQuery);
}
@NotNull @NotNull
private List<String> getList(String resourceType) { private List<String> getList(String resourceType) {
List<String> listType = new ArrayList<>(); List<String> listType = new ArrayList<>();