...
|
...
|
@@ -131,7 +131,7 @@ public class SearchLikeInShopService { |
|
|
// 1、设置SearchParam
|
|
|
SearchParam searchParam = new SearchParam();
|
|
|
// 2)设置query和filter
|
|
|
searchParam.setFiter(this.builderSearchLikeInShopFilter(productInfoInEs, productSkns));
|
|
|
searchParam.setFiter(this.builderSearchLikeInShopFilter(productInfoInEs, productSkns, true));
|
|
|
// 3、设置分页参数
|
|
|
searchParam.setOffset(0);
|
|
|
searchParam.setSize(productSkns.size());
|
...
|
...
|
@@ -153,7 +153,7 @@ public class SearchLikeInShopService { |
|
|
SearchParam searchParam = new SearchParam();
|
|
|
// 2)设置query和filter
|
|
|
searchParam.setQuery(this.buildeCharactersQueryBuilder(productInfoInEs, "20%"));
|
|
|
searchParam.setFiter(this.builderSearchLikeInShopFilter(productInfoInEs, null));
|
|
|
searchParam.setFiter(this.builderSearchLikeInShopFilter(productInfoInEs, null, false));
|
|
|
// 3、设置排序规则[按打分排序]
|
|
|
List<SortBuilder<?>> sortBuilders = new ArrayList<>();
|
|
|
sortBuilders.add(SortBuilders.scoreSort().order(SortOrder.DESC));
|
...
|
...
|
@@ -173,14 +173,13 @@ public class SearchLikeInShopService { |
|
|
return queryBuilder;
|
|
|
}
|
|
|
|
|
|
private BoolQueryBuilder builderSearchLikeInShopFilter(JSONObject productInfoInEs, List<String> inProductSkns) {
|
|
|
private BoolQueryBuilder builderSearchLikeInShopFilter(JSONObject productInfoInEs, List<String> inProductSkns, boolean needSameSort) {
|
|
|
//1) 默认参数
|
|
|
String productSkn = productInfoInEs.getString(ProductIndexEsField.productSkn);
|
|
|
String isGlobalInEs = productInfoInEs.getString(ProductIndexEsField.isGlobal);
|
|
|
boolean isGlobal = "Y".equalsIgnoreCase(isGlobalInEs);
|
|
|
BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(Arrays.asList(productSkn), isGlobal);
|
|
|
|
|
|
|
|
|
// 2)设置此SKN相关的性别过滤条件
|
|
|
String gender = productInfoInEs.getString(ProductIndexEsField.gender);
|
|
|
List<String> genderList = searchLikeHelper.getGenderInfo(gender);
|
...
|
...
|
@@ -202,8 +201,13 @@ public class SearchLikeInShopService { |
|
|
boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, inProductSkns));
|
|
|
}
|
|
|
|
|
|
// 5)同品类
|
|
|
Integer middleSortId = productInfoInEs.getInteger(ProductIndexEsField.middleSortId);
|
|
|
if (needSameSort && searchLikeHelper.isLegalInteger(middleSortId)) {
|
|
|
boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.middleSortId, middleSortId));
|
|
|
}
|
|
|
|
|
|
return boolFilter;
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|