Commit d61e307f by shenjunjie

渠道预警-竞品筛选调整

parent a08d18d6
...@@ -206,12 +206,15 @@ public class EsQueryTools { ...@@ -206,12 +206,15 @@ public class EsQueryTools {
} }
public static void assembleContendsQuery(BoolQueryBuilder query, Collection<String> contends) { public static void assembleContendsQuery(BoolQueryBuilder query, Collection<String> contends) {
if (CollectionUtils.isEmpty(contends)) { BoolQueryBuilder contendQuery = QueryBuilders.boolQuery();
return; // 本品舆情一定有
} contendQuery.should(cacheMapsNestedQuery(QueryBuilders.termQuery("brandkbs_cache_maps.contend_id.keyword", Constant.PRIMARY_CONTEND_ID)));
if (!CollectionUtils.isEmpty(contends)) {
for (String contendId : contends) { for (String contendId : contends) {
query.should(cacheMapsNestedQuery(QueryBuilders.termQuery("brandkbs_cache_maps.contend_id.keyword", contendId))); contendQuery.should(cacheMapsNestedQuery(QueryBuilders.termQuery("brandkbs_cache_maps.contend_id.keyword", contendId)));
}
} }
query.must(contendQuery);
} }
public static void assembleContendsQuery4Channel(BoolQueryBuilder query, Collection<String> contends) { public static void assembleContendsQuery4Channel(BoolQueryBuilder query, Collection<String> contends) {
......
...@@ -12,14 +12,16 @@ import com.zhiwei.brandkbs2.enmus.EmotionEnum; ...@@ -12,14 +12,16 @@ import com.zhiwei.brandkbs2.enmus.EmotionEnum;
import com.zhiwei.brandkbs2.es.EsClientDao; import com.zhiwei.brandkbs2.es.EsClientDao;
import com.zhiwei.brandkbs2.es.EsQueryTools; import com.zhiwei.brandkbs2.es.EsQueryTools;
import com.zhiwei.brandkbs2.model.ResponseResult; import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.*; import com.zhiwei.brandkbs2.pojo.AbstractProject;
import com.zhiwei.brandkbs2.pojo.BaseMap;
import com.zhiwei.brandkbs2.pojo.Channel;
import com.zhiwei.brandkbs2.pojo.Project;
import com.zhiwei.brandkbs2.pojo.external.*; import com.zhiwei.brandkbs2.pojo.external.*;
import com.zhiwei.brandkbs2.pojo.vo.CrisisCaseWarnVO; import com.zhiwei.brandkbs2.pojo.vo.CrisisCaseWarnVO;
import com.zhiwei.brandkbs2.service.ProjectService; import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.service.ProjectWarnService; import com.zhiwei.brandkbs2.service.ProjectWarnService;
import com.zhiwei.brandkbs2.util.RedisUtil; import com.zhiwei.brandkbs2.util.RedisUtil;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.event.core.EventClient;
import com.zhiwei.middleware.event.pojo.entity.Event; import com.zhiwei.middleware.event.pojo.entity.Event;
import com.zhiwei.middleware.event.pojo.entity.EventTagBasicInfo; import com.zhiwei.middleware.event.pojo.entity.EventTagBasicInfo;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -603,10 +605,8 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -603,10 +605,8 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
if (CollectionUtils.isNotEmpty(config.getMarkerTags())) { if (CollectionUtils.isNotEmpty(config.getMarkerTags())) {
config.getMarkerTags().forEach(tagName -> sourceBuilder.should(QueryBuilders.termQuery("brandkbs_mark_cache_maps.name.keyword", tagName))); config.getMarkerTags().forEach(tagName -> sourceBuilder.should(QueryBuilders.termQuery("brandkbs_mark_cache_maps.name.keyword", tagName)));
} }
if (CollectionUtils.isNotEmpty(config.getContends())) {
EsQueryTools.assembleContendsQuery(sourceBuilder, config.getContends());
}
postFilter.must(sourceBuilder); postFilter.must(sourceBuilder);
EsQueryTools.assembleContendsQuery(postFilter, config.getContends());
// postFilter.must(EsQueryTools.assembleNormalKeywordQuery(config.getKeyword(), new String[]{GenericAttribute.ES_IND_FULL_TEXT})); // postFilter.must(EsQueryTools.assembleNormalKeywordQuery(config.getKeyword(), new String[]{GenericAttribute.ES_IND_FULL_TEXT}));
helper.setPostFilter(postFilter); helper.setPostFilter(postFilter);
SearchHits searchHits = esClientDao.searchHits(helper); SearchHits searchHits = esClientDao.searchHits(helper);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment