Authored by 胡古飞

Merge branch 'master' into test

... ... @@ -83,15 +83,6 @@ public class SearchDynamicConfigService {
}
/**
* 某些字段降分是否打开
*
* @return
*/
public boolean deScoreFieldOpen() {
return configReader.getBoolean("search.degrade.open.descorefield", true);
}
/**
* 频道降分是否打开
*
* @return
... ...
package com.yoho.search.service.service.helper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
... ... @@ -31,31 +29,11 @@ public class FunctionScoreSearchHelper {
private SearchDynamicConfigService dynamicConfig;
static float globalWeight = 0.50f;
static float deScoreFieldWeight = 0.2f;
private WeightBuilder genWeightFactorBuilder(float factor) {
return ScoreFunctionBuilders.weightFactorFunction(factor);
}
private String[] getStringArrayFromParam(Map<String, String> paramMap, String paramName, boolean isNumic) {
String paramValue = paramMap.get(paramName);
if (StringUtils.isBlank(paramValue)) {
return null;
}
String[] values = paramValue.split(",");
if (!isNumic) {
return values;
}
List<String> results = new ArrayList<String>();
for (String value : values) {
if (StringUtils.isNumeric(value)) {
results.add(value);
}
}
return results.toArray(new String[results.size()]);
}
public QueryBuilder buildFunctionScoreQueryBuild(QueryBuilder queryBuilder, Map<String, String> paramMap) {
FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(queryBuilder);
// 将某个SKN展示到第一个
... ... @@ -80,27 +58,6 @@ public class FunctionScoreSearchHelper {
functionScoreQueryBuilder.add(physicalChannelQueryBuilder, ScoreFunctionBuilders.weightFactorFunction(physicalChannelWeight));
}
}
// 对某些属性降分【为了兼容,下个版本去除】
if (searchCommonHelper.isNeedDeScoreSomeFiled(paramMap)) {
// 对性别降分
String[] deScoreGenders = this.getStringArrayFromParam(paramMap, SearchRequestParams.DESOCRE_GENDER, false);
if (deScoreGenders != null && deScoreGenders.length > 0) {
functionScoreQueryBuilder.add(QueryBuilders.termsQuery("gender", deScoreGenders), ScoreFunctionBuilders.weightFactorFunction(deScoreFieldWeight));
}
// 对年龄层降分
String[] deScoreAgelevels = this.getStringArrayFromParam(paramMap, SearchRequestParams.DESOCRE_AGELEVEL, false);
if (deScoreAgelevels != null && deScoreAgelevels.length > 0) {
functionScoreQueryBuilder.add(QueryBuilders.termsQuery("ageLevel", deScoreAgelevels), ScoreFunctionBuilders.weightFactorFunction(deScoreFieldWeight));
}
// 对非小分类降分
String[] notSmallSortId = this.getStringArrayFromParam(paramMap, SearchRequestParams.DESOCRE_NOT_SORT, true);
if (notSmallSortId != null && notSmallSortId.length > 0) {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
TermsQueryBuilder termsQueryBuilder = QueryBuilders.termsQuery("smallSortId", notSmallSortId);
boolQueryBuilder.mustNot(termsQueryBuilder);
functionScoreQueryBuilder.add(boolQueryBuilder, ScoreFunctionBuilders.weightFactorFunction(deScoreFieldWeight));
}
}
functionScoreQueryBuilder.boostMode(CombineFunction.MULT);
return functionScoreQueryBuilder;
}
... ... @@ -145,7 +102,7 @@ public class FunctionScoreSearchHelper {
if (StringUtils.isNotBlank(query) && (query.contains("男") || query.contains("女"))) {
return true;
}
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_GENDER) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER))){
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_GENDER) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER))) {
return true;
}
return false;
... ...
... ... @@ -130,22 +130,6 @@ public class SearchCommonHelper {
}
/**
* 是否需要对某些字段降分
*
* @param paramMap
* @return
*/
public boolean isNeedDeScoreSomeFiled(Map<String, String> paramMap) {
if(!dynamicConfig.deScoreFieldOpen()){
return false;
}
if(isFuzzySearchDefault(paramMap)){
return true;
}
return false;
}
/**
* 判断搜索是否需要包含全球购
*
* @param paramMap
... ...
... ... @@ -83,11 +83,6 @@ public class SearchRequestParams {
public static final String SHOPS_PARAM_ISGLOBAL = "isGlobal";
public static final String FIRST_PRODUCRSKN = "firstProductSkn";
public static final String DESOCRE_GENDER = "descoreGender";
public static final String DESOCRE_AGELEVEL = "descoreAgeLevel";
public static final String DESOCRE_NOT_SORT = "descoreNotSort";
public static final String PHYSICAL_CHANNEL = "physical_channel";
}
... ...