...
|
...
|
@@ -131,7 +131,7 @@ public class SearchLikeInShopService { |
|
|
// 1、设置SearchParam
|
|
|
SearchParam searchParam = new SearchParam();
|
|
|
// 2)设置query和filter
|
|
|
searchParam.setFiter(this.builderSearchLikeFilter(productInfoInEs, productSkns));
|
|
|
searchParam.setFiter(this.builderSearchLikeInShopFilter(productInfoInEs, productSkns));
|
|
|
// 3、设置分页参数
|
|
|
searchParam.setOffset(0);
|
|
|
searchParam.setSize(productSkns.size());
|
...
|
...
|
@@ -141,32 +141,39 @@ public class SearchLikeInShopService { |
|
|
return searchParam;
|
|
|
}
|
|
|
|
|
|
private SearchParam buildCharactersSearchParam(JSONObject productInfoInEs, int viewNum) {
|
|
|
/**
|
|
|
* 店铺内按文字找相似
|
|
|
*
|
|
|
* @param productInfoInEs
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
public SearchParam buildCharactersSearchParam(JSONObject productInfoInEs, int pageSize) {
|
|
|
// 1、设置SearchParam
|
|
|
SearchParam searchParam = new SearchParam();
|
|
|
// 2)设置query和filter
|
|
|
searchParam.setQuery(this.buildCharactersQueryBuilder(productInfoInEs, "20%"));
|
|
|
searchParam.setFiter(this.builderSearchLikeFilter(productInfoInEs, null));
|
|
|
searchParam.setQuery(this.buildeCharactersQueryBuilder(productInfoInEs, "20%"));
|
|
|
searchParam.setFiter(this.builderSearchLikeInShopFilter(productInfoInEs, null));
|
|
|
// 3、设置排序规则[按打分排序]
|
|
|
List<SortBuilder<?>> sortBuilders = new ArrayList<SortBuilder<?>>();
|
|
|
List<SortBuilder<?>> sortBuilders = new ArrayList<>();
|
|
|
sortBuilders.add(SortBuilders.scoreSort().order(SortOrder.DESC));
|
|
|
searchParam.setSortBuilders(sortBuilders);
|
|
|
// 4、设置分页参数
|
|
|
searchParam.setOffset(0);
|
|
|
searchParam.setSize(viewNum);
|
|
|
searchParam.setSize(pageSize);
|
|
|
// 5)设置返回的参数【节省带宽】
|
|
|
List<String> includeFields = productIndexBaseService.getProductIndexIncludeFields();
|
|
|
searchParam.setIncludeFields(includeFields);
|
|
|
return searchParam;
|
|
|
}
|
|
|
|
|
|
private QueryBuilder buildCharactersQueryBuilder(JSONObject productInfoInEs, String minimumShouldMatch) {
|
|
|
private QueryBuilder buildeCharactersQueryBuilder(JSONObject productInfoInEs, String minimumShouldMatch) {
|
|
|
String queryString = searchLikeHelper.genYohoQueryStringWithBrandName(productInfoInEs);
|
|
|
QueryBuilder queryBuilder = searchLikeHelper.buildCharsetQueryBuilder(queryString, minimumShouldMatch);
|
|
|
return queryBuilder;
|
|
|
}
|
|
|
|
|
|
private BoolQueryBuilder builderSearchLikeFilter(JSONObject productInfoInEs, List<String> inProductSkns) {
|
|
|
private BoolQueryBuilder builderSearchLikeInShopFilter(JSONObject productInfoInEs, List<String> inProductSkns) {
|
|
|
//1) 默认参数
|
|
|
String productSkn = productInfoInEs.getString(ProductIndexEsField.productSkn);
|
|
|
String isGlobalInEs = productInfoInEs.getString(ProductIndexEsField.isGlobal);
|
...
|
...
|
|