Authored by hugufei

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

... ... @@ -145,6 +145,8 @@ public class FunctionScoreSearchHelper {
scorers.add(searchScorerFactory.getFirstShelveTimeScorer(FUZZY_FIRST_SHELVE_SCORE));
// 4、添加频道搜索
scorers.add(searchScorerFactory.getChannelSearchScorer(paramMap));
// 5、添加线下可售商品打分器
scorers.add(searchScorerFactory.getOfflineSaleOnlyScorer());
return scorers;
}
... ...
... ... @@ -106,4 +106,7 @@ public class SearchScorerFactory {
return new FeatureFactorScorer(scoreFilter, featureFactors, featureVersion);
}
public IScorer getOfflineSaleOnlyScorer() {
return new OfflineSaleOnlyScorer();
}
}
... ...
package com.yoho.search.service.scorer.impl;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.models.YohoFilterFunctionBuilders;
import com.yoho.search.service.scorer.IScorer;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
import java.util.Arrays;
/**
* 仅线下可售商品打分器
*/
public class OfflineSaleOnlyScorer implements IScorer {
private static final float OFFLINE_SALE_ONLY_WEIGHT = 0.90f;// 仅线下可售商品商品
@Override
public void addScorer(YohoFilterFunctionBuilders yohoFilterFunctionBuilders) {
yohoFilterFunctionBuilders.add(QueryBuilders.termsQuery(ProductIndexEsField.storeShowStatus, Arrays.asList("3", "4")), ScoreFunctionBuilders.weightFactorFunction(OFFLINE_SALE_ONLY_WEIGHT));
}
}
package com.yoho.search.service.scorer.impl;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.models.YohoFilterFunctionBuilders;
import com.yoho.search.service.scorer.IScorer;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
import java.util.Arrays;
/**
* 仅线下可售商品打分器
*/
public class OfflineSaleOnlyScorer implements IScorer {
private static final float OFFLINE_SALE_ONLY_WEIGHT = 0.90f;// 仅线下可售商品商品
@Override
public void addScorer(YohoFilterFunctionBuilders yohoFilterFunctionBuilders) {
yohoFilterFunctionBuilders.add(QueryBuilders.termsQuery(ProductIndexEsField.storeShowStatus, Arrays.asList("3", "4")), ScoreFunctionBuilders.weightFactorFunction(OFFLINE_SALE_ONLY_WEIGHT));
}
}
... ...