...
|
...
|
@@ -13,6 +13,8 @@ import org.elasticsearch.index.query.TermsQueryBuilder; |
|
|
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
|
|
|
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
|
|
|
import org.elasticsearch.index.query.functionscore.weight.WeightBuilder;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
...
|
...
|
@@ -25,6 +27,8 @@ import com.yoho.search.service.vo.PhysicalChannelScore; |
|
|
@Component
|
|
|
public class FunctionScoreSearchHelper {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(FunctionScoreSearchHelper.class);
|
|
|
|
|
|
@Autowired
|
|
|
private SearchCommonHelper searchCommonHelper;
|
|
|
@Autowired
|
...
|
...
|
@@ -89,12 +93,17 @@ public class FunctionScoreSearchHelper { |
|
|
* @return
|
|
|
*/
|
|
|
public float getDescoreGenderWeight(String uid, float baseScore, String descoreGender) {
|
|
|
Map<String, Float> userGenderFloat = personalizedRedisService.getUserGenderFeature(uid);
|
|
|
Float userGenderWeight = userGenderFloat.get(descoreGender);
|
|
|
if (userGenderWeight == null) {
|
|
|
try {
|
|
|
Map<String, Float> userGenderFloat = personalizedRedisService.getUserGenderFeature(uid);
|
|
|
Float userGenderWeight = userGenderFloat.get(descoreGender);
|
|
|
if (userGenderWeight == null) {
|
|
|
return baseScore;
|
|
|
}
|
|
|
return 0.5f * (1 + userGenderWeight);
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
return baseScore;
|
|
|
}
|
|
|
return baseScore * (1 + userGenderWeight);
|
|
|
}
|
|
|
|
|
|
private List<PhysicalChannelScore> getPhysicalChannelQueryBuilder(Map<String, String> paramMap) {
|
...
|
...
|
|