...
|
...
|
@@ -124,7 +124,7 @@ public class SearchLikeServiceImpl implements ISearchLikeService { |
|
|
}
|
|
|
|
|
|
// 4、获取同一个品牌下一半商品
|
|
|
JSONArray inBrandProductList = this.getProductListInBrand(productInfoInEs, paramMap, pageSize/2);
|
|
|
JSONArray inBrandProductList = this.getProductListInBrand(productInfoInEs, paramMap, pageSize / 2);
|
|
|
|
|
|
// 5、获取不同品牌下的余下数量的商品[通过聚合的方式来查找]
|
|
|
List<String> notInProductSkns = new ArrayList<String>();
|
...
|
...
|
@@ -312,9 +312,9 @@ public class SearchLikeServiceImpl implements ISearchLikeService { |
|
|
String brandName = productInfoInEs.getString("brandName");
|
|
|
String query = standardOnlyNames + "," + style;
|
|
|
if (isInBrand) {
|
|
|
query = brandName + "," + productName + "," + query;
|
|
|
}else{
|
|
|
query = productName.replaceAll(brandName, "") +","+ query;
|
|
|
query = brandName + "," + productName + "," + query;
|
|
|
} else {
|
|
|
query = productName.replaceAll(brandName, "") + "," + query;
|
|
|
}
|
|
|
// 2、设置字段权重
|
|
|
MultiMatchQueryBuilder multiMatchQueryBuilder = QueryBuilders.multiMatchQuery(query);
|
...
|
...
|
@@ -324,21 +324,32 @@ public class SearchLikeServiceImpl implements ISearchLikeService { |
|
|
}
|
|
|
// 3、设置匹配度
|
|
|
if (isInBrand) {
|
|
|
multiMatchQueryBuilder.minimumShouldMatch("50%");
|
|
|
multiMatchQueryBuilder.minimumShouldMatch("30%");
|
|
|
} else {
|
|
|
multiMatchQueryBuilder.minimumShouldMatch("70%");
|
|
|
multiMatchQueryBuilder.minimumShouldMatch("30%");
|
|
|
}
|
|
|
// 4、添加个性化打分
|
|
|
QueryBuilder queryBuilder = functionScoreSearchHelper.buildFunctionScoreQueryBuild(multiMatchQueryBuilder, paramMap);
|
|
|
return queryBuilder;
|
|
|
}
|
|
|
|
|
|
private List<String> getGenderInfo(String gender) {
|
|
|
if ("1".equals(gender)) {
|
|
|
return Arrays.asList("1", "3");
|
|
|
}
|
|
|
if ("2".equals(gender)) {
|
|
|
return Arrays.asList("2", "3");
|
|
|
}
|
|
|
return Arrays.asList("1", "2", "3");
|
|
|
}
|
|
|
|
|
|
private BoolQueryBuilder genBoolQueryBuilder(JSONObject productInfoInEs, Map<String, String> paramMap, List<String> notProductSkns, boolean isInBrand) {
|
|
|
BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
|
|
|
// 1)设置此SKN相关的过滤条件
|
|
|
String gender = productInfoInEs.getString("gender");
|
|
|
if (!StringUtils.isBlank(gender)) {
|
|
|
boolFilter.must(QueryBuilders.termQuery("gender", gender));
|
|
|
List<String> genderList = this.getGenderInfo(gender);
|
|
|
if (genderList != null) {
|
|
|
boolFilter.must(QueryBuilders.termsQuery("gender", genderList.toArray(new String[genderList.size()])));
|
|
|
}
|
|
|
// 2)找相似要具体到到中分类或小分类,大分类范围太广
|
|
|
BoolQueryBuilder sortFilter = QueryBuilders.boolQuery();
|
...
|
...
|
|