Authored by 胡古飞

降级的时候也要走个性化

... ... @@ -141,7 +141,7 @@ public class SearchServiceHelper {
// 4.设置查询字段和比重【AND表示多字段都要匹配,可提高精确度】
this.setDefaultSearchField(queryBuilder, paramMap);
queryBuilder.operator(MatchQueryBuilder.Operator.OR);
queryBuilder.minimumShouldMatch("50%");
queryBuilder.minimumShouldMatch("75%");
return queryBuilder;
}
... ... @@ -166,6 +166,13 @@ public class SearchServiceHelper {
// }
// return queryBuilder;
}
public QueryBuilder constructOrQueryBuilderForProductList(Map<String, String> paramMap) {
QueryBuilder queryBuilder = this.constructOrQueryBuilder(paramMap);
queryBuilder = this.buildPersonalSearch(queryBuilder, paramMap);
queryBuilder = this.buildFunctionScoreQueryBuild(queryBuilder, paramMap);
return queryBuilder;
}
/**
* 构建个性化的QueryBuilder
... ...
... ... @@ -101,7 +101,7 @@ public class ProductListServiceImpl implements IProductListService {
if (StringUtils.isNotBlank(queryWord) && 0 == searchResult.getTotal()) {
searchKeyWordService.handleEmptyRecords(paramMap);
logger.info("search result is empty by operator of AND, will use operator of OR to reenforce search result");
searchParam.setQuery(searchServiceHelper.constructOrQueryBuilder(paramMap));
searchParam.setQuery(searchServiceHelper.constructOrQueryBuilderForProductList(paramMap));
searchResult = searchCommonService.doSearch(indexNames, searchParam);
}
... ...