Authored by hugufei

添加ufo商品的降分逻辑

package com.yoho.search.service.helper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.SearchPageIdDefine;
import com.yoho.search.common.SearchDynamicConfigService;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.core.personalized.models.PersonalizedSearch;
import com.yoho.search.models.FirstShelveTimeScore;
import com.yoho.search.service.recall.config.SpecialShopConstants;
import com.yoho.search.service.scene.general.ProductCountService;
import com.yoho.search.service.scorer.IScorer;
import com.yoho.search.service.scorer.SearchScorerFactory;
import com.yoho.search.service.scorer.YohoFilterFunctionBuilders;
import com.yoho.search.service.scorer.personal.PersonalVectorFeatureSearch;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
... ... @@ -22,16 +26,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import com.yoho.search.base.utils.SearchPageIdDefine;
import com.yoho.search.core.personalized.models.PersonalizedSearch;
import com.yoho.search.models.FirstShelveTimeScore;
import com.yoho.search.service.scorer.YohoFilterFunctionBuilders;
import com.yoho.search.common.SearchDynamicConfigService;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.service.scorer.IScorer;
import com.yoho.search.service.scorer.SearchScorerFactory;
import com.yoho.search.service.scorer.personal.PersonalVectorFeatureSearch;
import com.yoho.search.service.scene.general.ProductCountService;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
public class FunctionScoreSearchHelper {
... ... @@ -193,8 +192,9 @@ public class FunctionScoreSearchHelper {
return new ArrayList<IScorer>();
}
List<IScorer> scorers = new ArrayList<IScorer>();
// 2、全球购商品
// 2、全球购和ufo商品
scorers.add(searchScorerFactory.getGlobalProductSearch(paramMap));
scorers.add(searchScorerFactory.getUfoProductSearch(paramMap));
// 3、一高三低商品降分[非新品并且零交际的商品]
scorers.add(searchScorerFactory.getProblemProductScorer());
// 4、first_product_skn
... ...
... ... @@ -50,10 +50,6 @@ public class SearchParamHelper {
return searchParam;
}
public ParamQueryFilter buildParamQueryFilter(Map<String, String> paramMap) throws Exception {
return buildParamQueryFilter(paramMap,false,null,null);
}
public ParamQueryFilter buildParamQueryFilter(Map<String, String> paramMap, boolean needPersional, BoolQueryBuilder mustFilter,String filterParamName) throws Exception {
// 1、构造filter
BoolQueryBuilder filter = searchQueryHelper.constructFilterBuilder(paramMap, filterParamName);
... ...
... ... @@ -37,6 +37,15 @@ public class SearchScorerFactory {
return new GlobalProductScorer();
}
// 获取【UFO商品】的打分器
public IScorer getUfoProductSearch(Map<String, String> paramMap) {
if (!searchCommonHelper.containUFO(paramMap)) {
return null;
}
return new UfoProductScorer();
}
// // 获取【断码商品】的打分器
// public IScorer getBreakSizeProductScorer(Map<String, String> paramMap) {
// try {
... ...
package com.yoho.search.service.scorer.impl;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.service.scorer.IScorer;
import com.yoho.search.service.scorer.YohoFilterFunctionBuilders;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
public class UfoProductScorer implements IScorer {
private static final float UFO_DEFUT_WEIGHT = 0.55f;// ufo得分
@Override
public void addScorer(YohoFilterFunctionBuilders yohoFilterFunctionBuilders) {
yohoFilterFunctionBuilders.add(QueryBuilders.termQuery(ProductIndexEsField.isUfo, "Y"), ScoreFunctionBuilders.weightFactorFunction(UFO_DEFUT_WEIGHT));
}
}
... ...