Authored by Gino Zhang

搜索关键词按天统计

... ... @@ -2,13 +2,13 @@ package com.yoho.search.service.common;
public class RedisKeys {
public static String YOHO_SEARCH_KEYWORDS_HOT = "YOHO.SEARCH.KEYWORDS.HOT";
public static String YOHO_SEARCH_KEYWORDS_HOT_TOKENS = YOHO_SEARCH_KEYWORDS_HOT + ".TOEKNS";
public static String YOHO_SEARCH_KEYWORDS_HOT = "YOHO.SEARCH.KEYWORDS.HOT.%s";
//public static String YOHO_SEARCH_KEYWORDS_HOT_TOKENS = YOHO_SEARCH_KEYWORDS_HOT + ".TOEKNS";
public static String YOHO_SEARCH_KEYWORDS_EMPTY = "YOHO.SEARCH.KEYWORDS.EMPTY";
public static String YOHO_SEARCH_KEYWORDS_EMPTY_TOKENS = YOHO_SEARCH_KEYWORDS_EMPTY + ".TOEKNS";
public static String YOHO_SEARCH_KEYWORDS_EMPTY = "YOHO.SEARCH.KEYWORDS.EMPTY.%s";
//public static String YOHO_SEARCH_KEYWORDS_EMPTY_TOKENS = YOHO_SEARCH_KEYWORDS_EMPTY + ".TOEKNS";
public static String YOHO_SEARCH_KEYWORDS_LESS = "YOHO.SEARCH.KEYWORDS.LESS";
public static String YOHO_SEARCH_KEYWORDS_LESS_TOKENS = YOHO_SEARCH_KEYWORDS_LESS + ".TOEKNS";
public static String YOHO_SEARCH_KEYWORDS_LESS = "YOHO.SEARCH.KEYWORDS.LESS.%s";
//public static String YOHO_SEARCH_KEYWORDS_LESS_TOKENS = YOHO_SEARCH_KEYWORDS_LESS + ".TOEKNS";
}
... ...
package com.yoho.search.service.service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.annotation.Resource;
import com.yoho.core.redis.YHZSetOperations;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.core.es.IElasticsearchClient;
import com.yoho.search.core.es.impl.YohoIndexHelper;
import com.yoho.search.service.common.RedisKeys;
import com.yoho.search.service.vo.KeyWordWithCount;
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -18,12 +14,14 @@ import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
import org.springframework.stereotype.Service;
import com.yoho.core.redis.YHZSetOperations;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.core.es.IElasticsearchClient;
import com.yoho.search.core.es.impl.YohoIndexHelper;
import com.yoho.search.service.common.RedisKeys;
import com.yoho.search.service.vo.KeyWordWithCount;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 将关键字结果存进redis中
... ... @@ -117,7 +115,7 @@ public class SearchKeyWordService {
/**
* 增加热搜词的次数
*
* @param query
* @param queryWord
*/
public void recordKeyWord(String queryWord) {
this.recordKeyWord(RedisKeys.YOHO_SEARCH_KEYWORDS_HOT, queryWord);
... ... @@ -149,7 +147,9 @@ public class SearchKeyWordService {
// 获取【热搜】toplist
public List<KeyWordWithCount> getHotkeyWordTokens(int limit) {
return this.getListByScoreDesc(RedisKeys.YOHO_SEARCH_KEYWORDS_HOT_TOKENS, limit);
//return this.getListByScoreDesc(RedisKeys.YOHO_SEARCH_KEYWORDS_HOT_TOKENS, limit);
// token没什么用处 先不存储
return new ArrayList<>();
}
// 获取空结果的toplist
... ... @@ -159,7 +159,9 @@ public class SearchKeyWordService {
// 获取空结果的toplist
public List<KeyWordWithCount> getEmptyKeyWordTokens(int limit) {
return this.getListByScoreDesc(RedisKeys.YOHO_SEARCH_KEYWORDS_EMPTY_TOKENS, limit);
//return this.getListByScoreDesc(RedisKeys.YOHO_SEARCH_KEYWORDS_EMPTY_TOKENS, limit);
// token没什么用处 先不存储
return new ArrayList<>();
}
// 获取只有一页结果的toplist
... ... @@ -169,7 +171,9 @@ public class SearchKeyWordService {
// 获取只有一页结果的toplist
public List<KeyWordWithCount> getLessKeyWordTokens(int limit) {
return this.getListByScoreDesc(RedisKeys.YOHO_SEARCH_KEYWORDS_LESS_TOKENS, limit);
//return this.getListByScoreDesc(RedisKeys.YOHO_SEARCH_KEYWORDS_LESS_TOKENS, limit);
// token没什么用处 先不存储
return new ArrayList<>();
}
private List<KeyWordWithCount> getListByScoreDesc(String redisKey, int limit) {
... ...