Showing
6 changed files
with
52 additions
and
7 deletions
@@ -3,6 +3,7 @@ package com.yoho.search.recall.beans.helper; | @@ -3,6 +3,7 @@ package com.yoho.search.recall.beans.helper; | ||
3 | import com.yoho.search.base.utils.DateUtil; | 3 | import com.yoho.search.base.utils.DateUtil; |
4 | import com.yoho.search.base.utils.ProductIndexEsField; | 4 | import com.yoho.search.base.utils.ProductIndexEsField; |
5 | import com.yoho.search.core.personalized.models.SortBrand; | 5 | import com.yoho.search.core.personalized.models.SortBrand; |
6 | +import com.yoho.search.recall.config.SpecialShopConstants; | ||
6 | import org.apache.lucene.search.join.ScoreMode; | 7 | import org.apache.lucene.search.join.ScoreMode; |
7 | import org.elasticsearch.index.query.BoolQueryBuilder; | 8 | import org.elasticsearch.index.query.BoolQueryBuilder; |
8 | import org.elasticsearch.index.query.QueryBuilder; | 9 | import org.elasticsearch.index.query.QueryBuilder; |
@@ -14,6 +15,7 @@ import java.util.List; | @@ -14,6 +15,7 @@ import java.util.List; | ||
14 | 15 | ||
15 | public class ExtendFilterHelper { | 16 | public class ExtendFilterHelper { |
16 | 17 | ||
18 | + | ||
17 | /** | 19 | /** |
18 | * 流量补偿的过滤器 | 20 | * 流量补偿的过滤器 |
19 | * | 21 | * |
@@ -24,6 +26,7 @@ public class ExtendFilterHelper { | @@ -24,6 +26,7 @@ public class ExtendFilterHelper { | ||
24 | filter.must(QueryBuilders.termQuery(ProductIndexEsField.flowType, "1")); | 26 | filter.must(QueryBuilders.termQuery(ProductIndexEsField.flowType, "1")); |
25 | filter.mustNot(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50)); | 27 | filter.mustNot(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50)); |
26 | filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); | 28 | filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); |
29 | + filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.shopId, SpecialShopConstants.QXJS_SHOP_ID)); | ||
27 | return filter; | 30 | return filter; |
28 | } | 31 | } |
29 | 32 | ||
@@ -37,6 +40,7 @@ public class ExtendFilterHelper { | @@ -37,6 +40,7 @@ public class ExtendFilterHelper { | ||
37 | filter.must(QueryBuilders.termQuery(ProductIndexEsField.toAddScore, "Y")); | 40 | filter.must(QueryBuilders.termQuery(ProductIndexEsField.toAddScore, "Y")); |
38 | filter.mustNot(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50)); | 41 | filter.mustNot(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50)); |
39 | filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); | 42 | filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); |
43 | + filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.shopId, SpecialShopConstants.QXJS_SHOP_ID)); | ||
40 | return filter; | 44 | return filter; |
41 | } | 45 | } |
42 | 46 | ||
@@ -221,6 +225,7 @@ public class ExtendFilterHelper { | @@ -221,6 +225,7 @@ public class ExtendFilterHelper { | ||
221 | filter.should(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); | 225 | filter.should(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); |
222 | //filter.should(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50)); | 226 | //filter.should(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50)); |
223 | filter.should(QueryBuilders.termsQuery(ProductIndexEsField.storeShowStatus, Arrays.asList("3", "4"))); | 227 | filter.should(QueryBuilders.termsQuery(ProductIndexEsField.storeShowStatus, Arrays.asList("3", "4"))); |
228 | + filter.should(QueryBuilders.termQuery(ProductIndexEsField.shopId, SpecialShopConstants.QXJS_SHOP_ID)); | ||
224 | return filter; | 229 | return filter; |
225 | } | 230 | } |
226 | 231 |
@@ -6,7 +6,7 @@ import java.util.List; | @@ -6,7 +6,7 @@ import java.util.List; | ||
6 | import java.util.Map; | 6 | import java.util.Map; |
7 | import java.util.stream.Collectors; | 7 | import java.util.stream.Collectors; |
8 | 8 | ||
9 | -import com.yoho.search.common.utils.SearchKeyWordUtils; | 9 | +import com.yoho.search.recall.config.SpecialShopConstants; |
10 | import org.apache.commons.collections.MapUtils; | 10 | import org.apache.commons.collections.MapUtils; |
11 | import org.apache.commons.lang.StringUtils; | 11 | import org.apache.commons.lang.StringUtils; |
12 | import org.elasticsearch.common.lucene.search.function.CombineFunction; | 12 | import org.elasticsearch.common.lucene.search.function.CombineFunction; |
@@ -151,6 +151,8 @@ public class FunctionScoreSearchHelper { | @@ -151,6 +151,8 @@ public class FunctionScoreSearchHelper { | ||
151 | if(StringUtils.isNotBlank(query)){ | 151 | if(StringUtils.isNotBlank(query)){ |
152 | scorers.add(searchScorerFactory.getCsBrandKeyWordScorer(query)); | 152 | scorers.add(searchScorerFactory.getCsBrandKeyWordScorer(query)); |
153 | } | 153 | } |
154 | + // 7、添加特殊店铺的打分器 | ||
155 | + scorers.add(searchScorerFactory.getSpecialShopScorer(SpecialShopConstants.DOWNGRADE_SHOPIDS, SpecialShopConstants.DOWNGRADE_SHOPID_WEIGHT)); | ||
154 | return scorers; | 156 | return scorers; |
155 | } | 157 | } |
156 | 158 |
@@ -114,4 +114,9 @@ public class SearchScorerFactory { | @@ -114,4 +114,9 @@ public class SearchScorerFactory { | ||
114 | public IScorer getCsBrandKeyWordScorer(String query) { | 114 | public IScorer getCsBrandKeyWordScorer(String query) { |
115 | return new CsBrandKeyWordScorer(query); | 115 | return new CsBrandKeyWordScorer(query); |
116 | } | 116 | } |
117 | + | ||
118 | + // 获取CsBrandKeyWord的打分器 | ||
119 | + public IScorer getSpecialShopScorer(List<Integer> shopIds,float weight) { | ||
120 | + return new SpecialShopScorer(shopIds,weight); | ||
121 | + } | ||
117 | } | 122 | } |
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.List; | ||
10 | + | ||
11 | +public class SpecialShopScorer implements IScorer { | ||
12 | + | ||
13 | + private List<Integer> shopIds; | ||
14 | + private float weight; | ||
15 | + | ||
16 | + public SpecialShopScorer(List<Integer> shopIds, float weight) { | ||
17 | + this.shopIds = shopIds; | ||
18 | + this.weight = weight; | ||
19 | + } | ||
20 | + | ||
21 | + @Override | ||
22 | + public void addScorer(YohoFilterFunctionBuilders yohoFilterFunctionBuilders) { | ||
23 | + yohoFilterFunctionBuilders.add(QueryBuilders.termsQuery(ProductIndexEsField.shopId, shopIds), ScoreFunctionBuilders.weightFactorFunction(weight)); | ||
24 | + } | ||
25 | + | ||
26 | +} |
@@ -11,6 +11,7 @@ import com.yoho.search.core.es.model.SearchResult; | @@ -11,6 +11,7 @@ import com.yoho.search.core.es.model.SearchResult; | ||
11 | import com.yoho.search.core.es.utils.SearchFieldUtils; | 11 | import com.yoho.search.core.es.utils.SearchFieldUtils; |
12 | import com.yoho.search.models.SearchApiResult; | 12 | import com.yoho.search.models.SearchApiResult; |
13 | import com.yoho.search.models.SearchSort; | 13 | import com.yoho.search.models.SearchSort; |
14 | +import com.yoho.search.recall.config.SpecialShopConstants; | ||
14 | import com.yoho.search.service.base.SearchCommonService; | 15 | import com.yoho.search.service.base.SearchCommonService; |
15 | import com.yoho.search.service.base.SearchRequestParams; | 16 | import com.yoho.search.service.base.SearchRequestParams; |
16 | import com.yoho.search.service.base.index.BrandIndexBaseService; | 17 | import com.yoho.search.service.base.index.BrandIndexBaseService; |
@@ -27,8 +28,6 @@ import org.elasticsearch.index.query.QueryBuilders; | @@ -27,8 +28,6 @@ import org.elasticsearch.index.query.QueryBuilders; | ||
27 | import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; | 28 | import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; |
28 | import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder.FilterFunctionBuilder; | 29 | import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder.FilterFunctionBuilder; |
29 | import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders; | 30 | import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders; |
30 | -import org.elasticsearch.search.SearchHit; | ||
31 | -import org.elasticsearch.search.SearchHits; | ||
32 | import org.elasticsearch.search.aggregations.AbstractAggregationBuilder; | 31 | import org.elasticsearch.search.aggregations.AbstractAggregationBuilder; |
33 | import org.elasticsearch.search.aggregations.Aggregation; | 32 | import org.elasticsearch.search.aggregations.Aggregation; |
34 | import org.elasticsearch.search.aggregations.AggregationBuilders; | 33 | import org.elasticsearch.search.aggregations.AggregationBuilders; |
@@ -178,10 +177,7 @@ public class ShopListServiceImpl implements IShopListService { | @@ -178,10 +177,7 @@ public class ShopListServiceImpl implements IShopListService { | ||
178 | } | 177 | } |
179 | 178 | ||
180 | //店铺搜索屏蔽【球鞋集市】 | 179 | //店铺搜索屏蔽【球鞋集市】 |
181 | - Integer qxjsShopId = 3504; | ||
182 | - if(yohoShopIds.contains(qxjsShopId)){ | ||
183 | - yohoShopIds.remove(qxjsShopId); | ||
184 | - } | 180 | + yohoShopIds.removeAll(SpecialShopConstants.DOWNGRADE_SHOPIDS); |
185 | 181 | ||
186 | // 获取有货状态为1的店铺 | 182 | // 获取有货状态为1的店铺 |
187 | Map<String, Map<String, Object>> yohoShopMap = this.queryYohoValidShopMap(yohoShopIds); | 183 | Map<String, Map<String, Object>> yohoShopMap = this.queryYohoValidShopMap(yohoShopIds); |
-
Please register or login to post a comment