...
|
...
|
@@ -35,7 +35,6 @@ import com.yoho.search.base.utils.ISearchConstants; |
|
|
import com.yoho.search.core.es.model.SearchParam;
|
|
|
import com.yoho.search.core.es.model.SearchResult;
|
|
|
import com.yoho.search.service.cache.CacheEnum;
|
|
|
import com.yoho.search.service.personalized.PersonalVectorFeatureSearch;
|
|
|
import com.yoho.search.service.service.SearchCacheService;
|
|
|
import com.yoho.search.service.service.SearchCommonService;
|
|
|
import com.yoho.search.service.service.helper.AggProductListHelper;
|
...
|
...
|
@@ -55,8 +54,6 @@ public class GoodProductListService implements IGoodProductsService { |
|
|
@Autowired
|
|
|
private SearchServiceHelper searchServiceHelper;
|
|
|
@Autowired
|
|
|
private FunctionScoreSearchHelper functionScoreSearchHelper;
|
|
|
@Autowired
|
|
|
private SearchCacheService searchCacheService;
|
|
|
@Autowired
|
|
|
private AggProductListHelper aggProductListHelper;
|
...
|
...
|
@@ -65,7 +62,7 @@ public class GoodProductListService implements IGoodProductsService { |
|
|
@Autowired
|
|
|
private SearchCommonHelper searchCommonHelper;
|
|
|
@Autowired
|
|
|
private PersonalVectorFeatureSearch personalVectorFeatureSearch;
|
|
|
private FunctionScoreSearchHelper functionScoreSearchHelper;
|
|
|
|
|
|
private final int maxSmallSortCount = 20;
|
|
|
private final int maxProductSknCountPerSort = 5;
|
...
|
...
|
@@ -138,14 +135,14 @@ public class GoodProductListService implements IGoodProductsService { |
|
|
if (recommendedSknList != null && !recommendedSknList.isEmpty()) {
|
|
|
Map<Integer, List<String>> recommondSknMap = this.splitProductSkns(recommendedSknList, maxCountPerGroup);
|
|
|
float currentGroupScore = recommendedSknMaxScore;
|
|
|
for (Map.Entry<Integer, List<String>> entry: recommondSknMap.entrySet()) {
|
|
|
for (Map.Entry<Integer, List<String>> entry : recommondSknMap.entrySet()) {
|
|
|
functionScoreQueryBuilder.add(QueryBuilders.termsQuery("productSkn", entry.getValue()), ScoreFunctionBuilders.weightFactorFunction(currentGroupScore));
|
|
|
currentGroupScore = currentGroupScore - 10;
|
|
|
}
|
|
|
}
|
|
|
// 加上个性化打分
|
|
|
if (searchCommonHelper.isNeedPersonalSearch(paramMap)) {
|
|
|
personalVectorFeatureSearch.addPersonalizedScriptScore(functionScoreQueryBuilder, paramMap);
|
|
|
functionScoreSearchHelper.addPersonalizedScriptScore(functionScoreQueryBuilder, paramMap);
|
|
|
}
|
|
|
return functionScoreQueryBuilder;
|
|
|
}
|
...
|
...
|
@@ -246,10 +243,8 @@ public class GoodProductListService implements IGoodProductsService { |
|
|
if (!StringUtils.isBlank(productSkns)) {
|
|
|
functionScoreQueryBuilder.add(QueryBuilders.termsQuery("productSkn", productSkns.split(",")), ScoreFunctionBuilders.weightFactorFunction(100));
|
|
|
}
|
|
|
// 加上个性化打分
|
|
|
if (searchCommonHelper.isNeedPersonalSearch(paramMap)) {
|
|
|
personalVectorFeatureSearch.addPersonalizedScriptScore(functionScoreQueryBuilder, paramMap);
|
|
|
}
|
|
|
// 强制加上个性化打分
|
|
|
functionScoreSearchHelper.addPersonalizedScriptScore(functionScoreQueryBuilder, paramMap);
|
|
|
searchParam.setQuery(functionScoreQueryBuilder);
|
|
|
|
|
|
// 4、设置聚合条件
|
...
|
...
|
@@ -345,7 +340,7 @@ public class GoodProductListService implements IGoodProductsService { |
|
|
public static void main(String[] args) {
|
|
|
List<String> list = new ArrayList<String>();
|
|
|
for (int i = 1; i <= 99; i++) {
|
|
|
list.add(i+"");
|
|
|
list.add(i + "");
|
|
|
}
|
|
|
Map<Integer, List<String>> results = new GoodProductListService().splitProductSkns(list, 20);
|
|
|
for (Map.Entry<Integer, List<String>> entry : results.entrySet()) {
|
...
|
...
|
|