Commit a1f6dcb2 by shenjunjie

标签请求匹配调整

parent 36743b27
...@@ -12,6 +12,7 @@ import org.apache.lucene.search.join.ScoreMode; ...@@ -12,6 +12,7 @@ import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.index.query.*; import org.elasticsearch.index.query.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import static com.zhiwei.brandkbs2.common.GenericAttribute.ES_BRANDKBS_CACHE_MAPS; import static com.zhiwei.brandkbs2.common.GenericAttribute.ES_BRANDKBS_CACHE_MAPS;
import static com.zhiwei.brandkbs2.util.Tools.concat; import static com.zhiwei.brandkbs2.util.Tools.concat;
...@@ -82,11 +83,15 @@ public class EsQueryTools { ...@@ -82,11 +83,15 @@ public class EsQueryTools {
* @return * @return
*/ */
public static BoolQueryBuilder assembleTagQuery(List<String> tagIds) { public static BoolQueryBuilder assembleTagQuery(List<String> tagIds) {
BoolQueryBuilder tagQuery = QueryBuilders.boolQuery(); // groupId分组处理
tagIds.forEach(e -> { Map<String, List<String>> groupTagIds = tagIds.stream().collect(Collectors.groupingBy(tagId -> tagId.substring(0, 4)));
tagQuery.should(QueryBuilders.termQuery("brandkbs_mark_cache_maps.unique_id.keyword", e)); BoolQueryBuilder tagBoolQuery = QueryBuilders.boolQuery();
groupTagIds.forEach((group, list) -> {
BoolQueryBuilder tagQuery = QueryBuilders.boolQuery();
list.forEach(e -> tagQuery.should(QueryBuilders.termQuery("brandkbs_mark_cache_maps.unique_id.keyword", e)));
tagBoolQuery.must(tagQuery);
}); });
return tagQuery; return tagBoolQuery;
} }
public static BoolQueryBuilder assembleCacheMapsQuery(String projectId, String linkedGroupId, String contendId) { public static BoolQueryBuilder assembleCacheMapsQuery(String projectId, String linkedGroupId, String contendId) {
......
...@@ -1041,7 +1041,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -1041,7 +1041,7 @@ public class ChannelServiceImpl implements ChannelService {
Long endTime = timeRangeWeek[1]; Long endTime = timeRangeWeek[1];
String contendId = Constant.PRIMARY_CONTEND_ID; String contendId = Constant.PRIMARY_CONTEND_ID;
JSONObject result = getSpreadingTend(channelId, type,contendId, startTime, endTime); JSONObject result = getSpreadingTend(channelId, type,contendId, startTime, endTime);
if ("稿件".equals(type)) { if (!"事件".equals(type)) {
List<ChannelIndex.Article> dataList = getSourceContendMap(channelId, Collections.singletonList(contendId),startTime,endTime).get(contendId); List<ChannelIndex.Article> dataList = getSourceContendMap(channelId, Collections.singletonList(contendId),startTime,endTime).get(contendId);
int dataSize = dataList.size(); int dataSize = dataList.size();
long positiveArticle = dataList.stream().filter(data -> EmotionEnum.POSITIVE.getState() == data.getEmotion()).count(); long positiveArticle = dataList.stream().filter(data -> EmotionEnum.POSITIVE.getState() == data.getEmotion()).count();
...@@ -1061,7 +1061,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -1061,7 +1061,7 @@ public class ChannelServiceImpl implements ChannelService {
}, esSearchExecutor)).collect(Collectors.toList()); }, esSearchExecutor)).collect(Collectors.toList());
CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0])).join(); CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0])).join();
result.put("recentlyArticles", futureList.stream().map(CompletableFuture::join).collect(Collectors.toList())); result.put("recentlyArticles", futureList.stream().map(CompletableFuture::join).collect(Collectors.toList()));
} else if ("事件".equals(type)) { } else {
Map<Long,List<Event>> eventMap = eventMiddlewareDao.getEventDay(new ChannelIndex(channelDao.findOneById(channelId), contendId).getFid(), startTime, Map<Long,List<Event>> eventMap = eventMiddlewareDao.getEventDay(new ChannelIndex(channelDao.findOneById(channelId), contendId).getFid(), startTime,
endTime); endTime);
List<Event> events = new ArrayList<>(); List<Event> events = new ArrayList<>();
......
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