Showing
1 changed file
with
3 additions
and
12 deletions
@@ -9,7 +9,6 @@ import com.yoho.search.core.es.model.SearchResult; | @@ -9,7 +9,6 @@ import com.yoho.search.core.es.model.SearchResult; | ||
9 | import com.yoho.search.core.es.utils.IgnoreSomeException; | 9 | import com.yoho.search.core.es.utils.IgnoreSomeException; |
10 | import com.yoho.search.service.service.SearchCacheService; | 10 | import com.yoho.search.service.service.SearchCacheService; |
11 | import com.yoho.search.service.service.SearchCommonService; | 11 | import com.yoho.search.service.service.SearchCommonService; |
12 | -import com.yoho.search.service.service.SearchKeyWordService; | ||
13 | import com.yoho.search.service.servicenew.ISuggestService; | 12 | import com.yoho.search.service.servicenew.ISuggestService; |
14 | import com.yoho.search.service.utils.HttpServletRequestUtils; | 13 | import com.yoho.search.service.utils.HttpServletRequestUtils; |
15 | import com.yoho.search.service.utils.SearchRequestParams; | 14 | import com.yoho.search.service.utils.SearchRequestParams; |
@@ -55,8 +54,6 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | @@ -55,8 +54,6 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | ||
55 | private SearchCommonService searchCommonService; | 54 | private SearchCommonService searchCommonService; |
56 | @Autowired | 55 | @Autowired |
57 | private SearchCacheService searchCacheService; | 56 | private SearchCacheService searchCacheService; |
58 | - @Autowired | ||
59 | - private SearchKeyWordService searchKeyWordService; | ||
60 | 57 | ||
61 | private ApplicationEventPublisher publisher; | 58 | private ApplicationEventPublisher publisher; |
62 | 59 | ||
@@ -223,6 +220,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | @@ -223,6 +220,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | ||
223 | * @return 包括term建议和phrase建议。 | 220 | * @return 包括term建议和phrase建议。 |
224 | */ | 221 | */ |
225 | public JSONObject suggestByTerms(Map<String, String> paramMap) { | 222 | public JSONObject suggestByTerms(Map<String, String> paramMap) { |
223 | + // 1) 对query进行判断 为空时不处理 | ||
226 | String queryWord = paramMap.get(SearchRequestParams.PARAM_SEARCH_KEYWORD); | 224 | String queryWord = paramMap.get(SearchRequestParams.PARAM_SEARCH_KEYWORD); |
227 | if (StringUtils.isEmpty(queryWord)) { | 225 | if (StringUtils.isEmpty(queryWord)) { |
228 | return null; | 226 | return null; |
@@ -232,15 +230,8 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | @@ -232,15 +230,8 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | ||
232 | long begin = System.currentTimeMillis(); | 230 | long begin = System.currentTimeMillis(); |
233 | logger.info("[func=suggestByTerms][query={}][begin={}]", queryWord, begin); | 231 | logger.info("[func=suggestByTerms][query={}][begin={}]", queryWord, begin); |
234 | 232 | ||
235 | - // 1) 对query进行分词 不考虑同义词处理 使用ik_smart | ||
236 | - List<String> termsForQueryWord = searchKeyWordService.getAnalyzeTerms(queryWord, "ik_smart"); | ||
237 | - logger.info("[func=suggestByTerms][termsForQueryWord={}]", termsForQueryWord); | ||
238 | - if (CollectionUtils.isEmpty(termsForQueryWord) || termsForQueryWord.size() == 1) { | ||
239 | - return null; | ||
240 | - } | ||
241 | - | ||
242 | // 2) 根据terms搜索构造搜索请求 | 233 | // 2) 根据terms搜索构造搜索请求 |
243 | - SearchParam searchParam = buildSearchParamForTerms(paramMap, termsForQueryWord); | 234 | + SearchParam searchParam = buildSearchParamForTerms(paramMap); |
244 | 235 | ||
245 | // 3) 先从缓存中获取 | 236 | // 3) 先从缓存中获取 |
246 | final String indexName = ISearchConstants.INDEX_NAME_SUGGEST; | 237 | final String indexName = ISearchConstants.INDEX_NAME_SUGGEST; |
@@ -274,7 +265,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | @@ -274,7 +265,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | ||
274 | } | 265 | } |
275 | } | 266 | } |
276 | 267 | ||
277 | - private SearchParam buildSearchParamForTerms(Map<String, String> paramMap, List<String> termsForQueryWord) { | 268 | + private SearchParam buildSearchParamForTerms(Map<String, String> paramMap) { |
278 | final String countField = getCountField(paramMap); | 269 | final String countField = getCountField(paramMap); |
279 | SearchParam searchParam = new SearchParam(); | 270 | SearchParam searchParam = new SearchParam(); |
280 | MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(paramMap.get(SearchRequestParams.PARAM_SEARCH_KEYWORD)); | 271 | MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(paramMap.get(SearchRequestParams.PARAM_SEARCH_KEYWORD)); |
-
Please register or login to post a comment