Authored by hugufei

模糊搜索时,仅线下可售商品降权

  1 +package com.yoho.search.service.scorer.impl;
  2 +
  3 +import com.yoho.search.base.utils.ProductIndexEsField;
  4 +import com.yoho.search.models.YohoFilterFunctionBuilders;
  5 +import com.yoho.search.service.scorer.IScorer;
  6 +import org.elasticsearch.index.query.QueryBuilders;
  7 +import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
  8 +
  9 +import java.util.Arrays;
  10 +
  11 +/**
  12 + * 仅线下可售商品打分器
  13 + */
  14 +public class OfflineSaleOnlyScorer implements IScorer {
  15 +
  16 + private static final float OFFLINE_SALE_ONLY_WEIGHT = 0.90f;// 仅线下可售商品商品
  17 +
  18 + @Override
  19 + public void addScorer(YohoFilterFunctionBuilders yohoFilterFunctionBuilders) {
  20 + yohoFilterFunctionBuilders.add(QueryBuilders.termsQuery(ProductIndexEsField.storeShowStatus, Arrays.asList("3", "4")), ScoreFunctionBuilders.weightFactorFunction(OFFLINE_SALE_ONLY_WEIGHT));
  21 + }
  22 +}
@@ -88,7 +88,6 @@ public class UserChannelSearchScorer implements IScorer { @@ -88,7 +88,6 @@ public class UserChannelSearchScorer implements IScorer {
88 /** 88 /**
89 * 获取将要降分的性别权重 89 * 获取将要降分的性别权重
90 * 90 *
91 - * @param uid  
92 * @param baseScore 91 * @param baseScore
93 * @param descoreGender 92 * @param descoreGender
94 * @return 93 * @return