conversion优先采用完全匹配的source
Showing
1 changed file
with
7 additions
and
1 deletions
@@ -426,7 +426,13 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | @@ -426,7 +426,13 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | ||
426 | // 2) 根据terms搜索构造搜索请求 | 426 | // 2) 根据terms搜索构造搜索请求 |
427 | SearchParam searchParam = new SearchParam(); | 427 | SearchParam searchParam = new SearchParam(); |
428 | MatchQueryBuilder queryBuilder = QueryBuilders.matchQuery("source", queryWord); | 428 | MatchQueryBuilder queryBuilder = QueryBuilders.matchQuery("source", queryWord); |
429 | - searchParam.setQuery(queryBuilder); | 429 | + FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(queryBuilder); |
430 | + // 2.1) 优先取完全匹配的Term | ||
431 | + functionScoreQueryBuilder.add(QueryBuilders.termQuery("source.source_keyword", queryWord.trim().toLowerCase()), | ||
432 | + ScoreFunctionBuilders.weightFactorFunction(100)); | ||
433 | + functionScoreQueryBuilder.boostMode(CombineFunction.MULT); | ||
434 | + | ||
435 | + searchParam.setQuery(functionScoreQueryBuilder); | ||
430 | searchParam.setPage(1); | 436 | searchParam.setPage(1); |
431 | searchParam.setSize(1); | 437 | searchParam.setSize(1); |
432 | searchParam.setFiter(QueryBuilders.termQuery("status", 1)); | 438 | searchParam.setFiter(QueryBuilders.termQuery("status", 1)); |
-
Please register or login to post a comment