Authored by Gino Zhang

suggestList支持精确匹配 可以去重

@@ -542,7 +542,13 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl @@ -542,7 +542,13 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl
542 542
543 // 1) 构建ES请求 543 // 1) 构建ES请求
544 SearchParam searchParam = new SearchParam(); 544 SearchParam searchParam = new SearchParam();
545 - QueryBuilder queryBuilder = StringUtils.isNotEmpty(queryWord) ? QueryBuilders.matchQuery("keyword.keyword_ik", queryWord) : QueryBuilders.matchAllQuery(); 545 + QueryBuilder queryBuilder = QueryBuilders.matchAllQuery();
  546 + if (StringUtils.isNotEmpty(queryWord)) {
  547 + // 是否精确匹配
  548 + String accurateQuery = paramMap.get("accurate");
  549 + queryBuilder = "Y".equalsIgnoreCase(accurateQuery) ? QueryBuilders.matchQuery("standardKeyword", CharUtils.standardized(queryWord)) : QueryBuilders.matchQuery("keyword.keyword_ik", queryWord);
  550 + }
  551 +
546 searchParam.setQuery(queryBuilder); 552 searchParam.setQuery(queryBuilder);
547 searchParam.setPage(page); 553 searchParam.setPage(page);
548 searchParam.setOffset((page - 1) * 10); 554 searchParam.setOffset((page - 1) * 10);