...
|
...
|
@@ -38,18 +38,18 @@ public class FunctionScoreSearchHelper { |
|
|
return ScoreFunctionBuilders.weightFactorFunction(factor);
|
|
|
}
|
|
|
|
|
|
private String[] getStringArrayFromParam(Map<String, String> paramMap, String paramName,boolean isNumic){
|
|
|
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){
|
|
|
String[] values = paramValue.split(",");
|
|
|
if (!isNumic) {
|
|
|
return values;
|
|
|
}
|
|
|
List<String> results = new ArrayList<String>();
|
|
|
List<String> results = new ArrayList<String>();
|
|
|
for (String value : values) {
|
|
|
if(StringUtils.isNumeric(value)){
|
|
|
if (StringUtils.isNumeric(value)) {
|
|
|
results.add(value);
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -72,7 +72,14 @@ public class FunctionScoreSearchHelper { |
|
|
if (searchCommonHelper.isNeedDeScoreBrandSearch(paramMap)) {
|
|
|
functionScoreQueryBuilder.add(QueryBuilders.termQuery("isForbiddenSortBrand", "1"), ScoreFunctionBuilders.weightFactorFunction(0));
|
|
|
}
|
|
|
// 对某些属性降分
|
|
|
// 针对频道降分
|
|
|
if (searchCommonHelper.isNeedDeScoreForChannel(paramMap)) {
|
|
|
QueryBuilder physicalChannelQueryBuilder = this.getPhysicalChannelQueryBuilder(paramMap.get(SearchRequestParams.PHYSICAL_CHANNEL));
|
|
|
if (physicalChannelQueryBuilder != null) {
|
|
|
functionScoreQueryBuilder.add(physicalChannelQueryBuilder, ScoreFunctionBuilders.weightFactorFunction((float) dynamicConfig.getDeScoreForChannelWeight()));
|
|
|
}
|
|
|
}
|
|
|
// 对某些属性降分【为了兼容,下个版本去除】
|
|
|
if (searchCommonHelper.isNeedDeScoreSomeFiled(paramMap)) {
|
|
|
// 对性别降分
|
|
|
String[] deScoreGenders = this.getStringArrayFromParam(paramMap, SearchRequestParams.DESOCRE_GENDER, false);
|
...
|
...
|
@@ -97,4 +104,32 @@ public class FunctionScoreSearchHelper { |
|
|
return functionScoreQueryBuilder;
|
|
|
}
|
|
|
|
|
|
private QueryBuilder getPhysicalChannelQueryBuilder(String physicalChannel) {
|
|
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
TermsQueryBuilder physicalChannelsTermsQueryBuilder = QueryBuilders.termsQuery("physicalChannels", physicalChannel);
|
|
|
// 男生频道,对非男生频道的商品或者性别女的降分
|
|
|
if (physicalChannel.equals("1")) {
|
|
|
boolQueryBuilder.should(QueryBuilders.boolQuery().mustNot(physicalChannelsTermsQueryBuilder));
|
|
|
boolQueryBuilder.should(QueryBuilders.termsQuery("gender", "2"));
|
|
|
return boolQueryBuilder;
|
|
|
}
|
|
|
// 女生频道,对非女生频道的商品或者性别男的降分
|
|
|
if (physicalChannel.equals("2")) {
|
|
|
boolQueryBuilder.should(QueryBuilders.boolQuery().mustNot(physicalChannelsTermsQueryBuilder));
|
|
|
boolQueryBuilder.should(QueryBuilders.termsQuery("gender", "1"));
|
|
|
return boolQueryBuilder;
|
|
|
}
|
|
|
// 潮童频道,对非潮童频道的或成人的商品降分
|
|
|
if (physicalChannel.equals("3")) {
|
|
|
boolQueryBuilder.should(QueryBuilders.boolQuery().mustNot(physicalChannelsTermsQueryBuilder));
|
|
|
boolQueryBuilder.should(QueryBuilders.termsQuery("ageLevel", "1"));
|
|
|
return boolQueryBuilder;
|
|
|
}
|
|
|
// 创意生活频道,对非创意生活频道的商品降分
|
|
|
if (physicalChannel.equals("4")) {
|
|
|
return boolQueryBuilder.mustNot(physicalChannelsTermsQueryBuilder);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|