Authored by hugufei

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

@@ -145,6 +145,8 @@ public class FunctionScoreSearchHelper { @@ -145,6 +145,8 @@ public class FunctionScoreSearchHelper {
145 scorers.add(searchScorerFactory.getFirstShelveTimeScorer(FUZZY_FIRST_SHELVE_SCORE)); 145 scorers.add(searchScorerFactory.getFirstShelveTimeScorer(FUZZY_FIRST_SHELVE_SCORE));
146 // 4、添加频道搜索 146 // 4、添加频道搜索
147 scorers.add(searchScorerFactory.getChannelSearchScorer(paramMap)); 147 scorers.add(searchScorerFactory.getChannelSearchScorer(paramMap));
  148 + // 5、添加线下可售商品打分器
  149 + scorers.add(searchScorerFactory.getOfflineSaleOnlyScorer());
148 return scorers; 150 return scorers;
149 } 151 }
150 152
@@ -106,4 +106,7 @@ public class SearchScorerFactory { @@ -106,4 +106,7 @@ public class SearchScorerFactory {
106 return new FeatureFactorScorer(scoreFilter, featureFactors, featureVersion); 106 return new FeatureFactorScorer(scoreFilter, featureFactors, featureVersion);
107 } 107 }
108 108
  109 + public IScorer getOfflineSaleOnlyScorer() {
  110 + return new OfflineSaleOnlyScorer();
  111 + }
109 } 112 }
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 -} 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 +}