suggest索引增加一个standardKeyword用于排重
Showing
1 changed file
with
3 additions
and
2 deletions
@@ -2,6 +2,7 @@ package com.yoho.search.service.servicenew.impl; | @@ -2,6 +2,7 @@ package com.yoho.search.service.servicenew.impl; | ||
2 | 2 | ||
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | import com.yoho.error.event.SearchEvent; | 4 | import com.yoho.error.event.SearchEvent; |
5 | +import com.yoho.search.base.utils.CharUtils; | ||
5 | import com.yoho.search.base.utils.EventReportEnum; | 6 | import com.yoho.search.base.utils.EventReportEnum; |
6 | import com.yoho.search.base.utils.ISearchConstants; | 7 | import com.yoho.search.base.utils.ISearchConstants; |
7 | import com.yoho.search.core.es.model.SearchParam; | 8 | import com.yoho.search.core.es.model.SearchParam; |
@@ -285,7 +286,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | @@ -285,7 +286,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | ||
285 | FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(QueryBuilders.constantScoreQuery(queryBuilder)); | 286 | FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(QueryBuilders.constantScoreQuery(queryBuilder)); |
286 | for (String term : termSet) { | 287 | for (String term : termSet) { |
287 | // 2.2) 对于完全匹配Term的加1分 | 288 | // 2.2) 对于完全匹配Term的加1分 |
288 | - functionScoreQueryBuilder.add(QueryBuilders.termQuery("keyword.keyword_lowercase", term.trim().toLowerCase()), | 289 | + functionScoreQueryBuilder.add(QueryBuilders.termQuery("standardKeyword", CharUtils.standardized(term)), |
289 | ScoreFunctionBuilders.weightFactorFunction(1)); | 290 | ScoreFunctionBuilders.weightFactorFunction(1)); |
290 | 291 | ||
291 | // 2.3) 对于匹配到一个Term的加2分 | 292 | // 2.3) 对于匹配到一个Term的加2分 |
@@ -300,7 +301,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | @@ -300,7 +301,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | ||
300 | 301 | ||
301 | BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); | 302 | BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); |
302 | boolFilter.must(QueryBuilders.rangeQuery(countField).gte(SMART_SUGGESTION_COUNT_LIMIT)); | 303 | boolFilter.must(QueryBuilders.rangeQuery(countField).gte(SMART_SUGGESTION_COUNT_LIMIT)); |
303 | - boolFilter.mustNot(QueryBuilders.termQuery("keyword.keyword_lowercase", queryWord.trim().toLowerCase())); | 304 | + boolFilter.mustNot(QueryBuilders.termQuery("standardKeyword", CharUtils.standardized(queryWord))); |
304 | searchParam.setFiter(boolFilter); | 305 | searchParam.setFiter(boolFilter); |
305 | 306 | ||
306 | // 2.4) 按照得分、权重、数量的规则降序排序 | 307 | // 2.4) 按照得分、权重、数量的规则降序排序 |
-
Please register or login to post a comment