...
|
...
|
@@ -74,7 +74,7 @@ public class FunctionScoreSearchHelper { |
|
|
}
|
|
|
// 针对频道降分
|
|
|
if (searchCommonHelper.isNeedDeScoreForChannel(paramMap)) {
|
|
|
QueryBuilder physicalChannelQueryBuilder = this.getPhysicalChannelQueryBuilder(paramMap.get(SearchRequestParams.PHYSICAL_CHANNEL));
|
|
|
QueryBuilder physicalChannelQueryBuilder = this.getPhysicalChannelQueryBuilder(paramMap);
|
|
|
if (physicalChannelQueryBuilder != null) {
|
|
|
float physicalChannelWeight = (float) dynamicConfig.getDeScorePhysicalChannelWeight();
|
|
|
functionScoreQueryBuilder.add(physicalChannelQueryBuilder, ScoreFunctionBuilders.weightFactorFunction(physicalChannelWeight));
|
...
|
...
|
@@ -105,9 +105,26 @@ public class FunctionScoreSearchHelper { |
|
|
return functionScoreQueryBuilder;
|
|
|
}
|
|
|
|
|
|
private QueryBuilder getPhysicalChannelQueryBuilder(String physicalChannel) {
|
|
|
private QueryBuilder getPhysicalChannelQueryBuilder(Map<String, String> paramMap) {
|
|
|
String physicalChannel = paramMap.get(SearchRequestParams.PHYSICAL_CHANNEL);
|
|
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
TermsQueryBuilder physicalChannelsTermsQueryBuilder = QueryBuilders.termsQuery("physicalChannels", physicalChannel);
|
|
|
// 潮童频道,对非潮童频道的或成人的商品降分
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
// 如果用户在男女频道的意图中包含了明显的性别意图,则只针对频道降分
|
|
|
if (isUserSearchContainGender(paramMap)) {
|
|
|
return boolQueryBuilder.mustNot(physicalChannelsTermsQueryBuilder);
|
|
|
}
|
|
|
|
|
|
// 男生频道,对非男生频道的商品或者性别女的降分
|
|
|
if (physicalChannel.equals("1")) {
|
|
|
boolQueryBuilder.should(QueryBuilders.boolQuery().mustNot(physicalChannelsTermsQueryBuilder));
|
...
|
...
|
@@ -120,17 +137,18 @@ public class FunctionScoreSearchHelper { |
|
|
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;
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private boolean isUserSearchContainGender(Map<String, String> paramMap) {
|
|
|
String query = paramMap.get("query");
|
|
|
if (StringUtils.isNotBlank(query) && (query.contains("男") || query.contains("女"))) {
|
|
|
return true;
|
|
|
}
|
|
|
// 创意生活频道,对非创意生活频道的商品降分
|
|
|
if (physicalChannel.equals("4")) {
|
|
|
return boolQueryBuilder.mustNot(physicalChannelsTermsQueryBuilder);
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_GENDER) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER))){
|
|
|
return true;
|
|
|
}
|
|
|
return null;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|