Showing
7 changed files
with
178 additions
and
55 deletions
@@ -7,7 +7,7 @@ import java.util.ArrayList; | @@ -7,7 +7,7 @@ import java.util.ArrayList; | ||
7 | import java.util.List; | 7 | import java.util.List; |
8 | 8 | ||
9 | /** | 9 | /** |
10 | - * 个性化因子参数 | 10 | + * 页面元素信息 |
11 | */ | 11 | */ |
12 | public class PagePersonalFactor implements Serializable { | 12 | public class PagePersonalFactor implements Serializable { |
13 | 13 | ||
@@ -16,6 +16,7 @@ public class PagePersonalFactor implements Serializable { | @@ -16,6 +16,7 @@ public class PagePersonalFactor implements Serializable { | ||
16 | private List<Integer> misortIds; | 16 | private List<Integer> misortIds; |
17 | private List<Integer> brandIds; | 17 | private List<Integer> brandIds; |
18 | private List<SortBrand> sortBrandList; | 18 | private List<SortBrand> sortBrandList; |
19 | + private List<Integer> addScorePoolIds; | ||
19 | 20 | ||
20 | public PagePersonalFactor() { | 21 | public PagePersonalFactor() { |
21 | this.misortIds = new ArrayList<>(); | 22 | this.misortIds = new ArrayList<>(); |
@@ -23,10 +24,11 @@ public class PagePersonalFactor implements Serializable { | @@ -23,10 +24,11 @@ public class PagePersonalFactor implements Serializable { | ||
23 | this.sortBrandList = new ArrayList<>(); | 24 | this.sortBrandList = new ArrayList<>(); |
24 | } | 25 | } |
25 | 26 | ||
26 | - public PagePersonalFactor(List<Integer> misortIds, List<Integer> brandIds, List<SortBrand> sortBrandList) { | 27 | + public PagePersonalFactor(List<Integer> misortIds, List<Integer> brandIds, List<SortBrand> sortBrandList, List<Integer> addScorePoolIds) { |
27 | this.misortIds = misortIds; | 28 | this.misortIds = misortIds; |
28 | this.brandIds = brandIds; | 29 | this.brandIds = brandIds; |
29 | this.sortBrandList = sortBrandList; | 30 | this.sortBrandList = sortBrandList; |
31 | + this.addScorePoolIds = addScorePoolIds; | ||
30 | } | 32 | } |
31 | 33 | ||
32 | public List<Integer> getMisortIds() { | 34 | public List<Integer> getMisortIds() { |
@@ -52,4 +54,12 @@ public class PagePersonalFactor implements Serializable { | @@ -52,4 +54,12 @@ public class PagePersonalFactor implements Serializable { | ||
52 | public void setSortBrandList(List<SortBrand> sortBrandList) { | 54 | public void setSortBrandList(List<SortBrand> sortBrandList) { |
53 | this.sortBrandList = sortBrandList; | 55 | this.sortBrandList = sortBrandList; |
54 | } | 56 | } |
57 | + | ||
58 | + public List<Integer> getAddScorePoolIds() { | ||
59 | + return addScorePoolIds; | ||
60 | + } | ||
61 | + | ||
62 | + public void setAddScorePoolIds(List<Integer> addScorePoolIds) { | ||
63 | + this.addScorePoolIds = addScorePoolIds; | ||
64 | + } | ||
55 | } | 65 | } |
@@ -8,6 +8,9 @@ import com.yoho.search.common.SearchCommonService; | @@ -8,6 +8,9 @@ import com.yoho.search.common.SearchCommonService; | ||
8 | import com.yoho.search.core.es.model.SearchParam; | 8 | import com.yoho.search.core.es.model.SearchParam; |
9 | import com.yoho.search.core.es.model.SearchResult; | 9 | import com.yoho.search.core.es.model.SearchResult; |
10 | import com.yoho.search.core.personalized.models.SortBrand; | 10 | import com.yoho.search.core.personalized.models.SortBrand; |
11 | +import com.yoho.search.models.aggregations.AggKeyCount; | ||
12 | +import com.yoho.search.models.aggregations.AggKeyCountTwoLevel; | ||
13 | +import com.yoho.search.service.helper.AggCommonHelper; | ||
11 | import com.yoho.search.service.helper.SearchParamHelper; | 14 | import com.yoho.search.service.helper.SearchParamHelper; |
12 | import com.yoho.search.service.recall.helper.ExtendFilterHelper; | 15 | import com.yoho.search.service.recall.helper.ExtendFilterHelper; |
13 | import com.yoho.search.models.recall.ParamQueryFilter; | 16 | import com.yoho.search.models.recall.ParamQueryFilter; |
@@ -78,12 +81,12 @@ public class QueryPageFactorBaseService extends AbstractCacheComponent<PagePerso | @@ -78,12 +81,12 @@ public class QueryPageFactorBaseService extends AbstractCacheComponent<PagePerso | ||
78 | filter.must(old.getFiter()); | 81 | filter.must(old.getFiter()); |
79 | filter.mustNot(ExtendFilterHelper.notRecallFilter());//聚合的时候带上不召回的数据 | 82 | filter.mustNot(ExtendFilterHelper.notRecallFilter());//聚合的时候带上不召回的数据 |
80 | searchParam.setFiter(filter); | 83 | searchParam.setFiter(filter); |
81 | - | ||
82 | searchParam.setSize(0); | 84 | searchParam.setSize(0); |
83 | 85 | ||
84 | //2、构造聚合参数 | 86 | //2、构造聚合参数 |
85 | List<AbstractAggregationBuilder<?>> aggregationBuilders = new ArrayList<>(); | 87 | List<AbstractAggregationBuilder<?>> aggregationBuilders = new ArrayList<>(); |
86 | aggregationBuilders.add(brandSortAggBuilder());//品类-品牌聚合 | 88 | aggregationBuilders.add(brandSortAggBuilder());//品类-品牌聚合 |
89 | + aggregationBuilders.add(addScorePoolIdsBuilder());//商品池聚合 | ||
87 | searchParam.setAggregationBuilders(aggregationBuilders); | 90 | searchParam.setAggregationBuilders(aggregationBuilders); |
88 | 91 | ||
89 | //3、执行查询 | 92 | //3、执行查询 |
@@ -91,10 +94,15 @@ public class QueryPageFactorBaseService extends AbstractCacheComponent<PagePerso | @@ -91,10 +94,15 @@ public class QueryPageFactorBaseService extends AbstractCacheComponent<PagePerso | ||
91 | 94 | ||
92 | //4、构造结果 | 95 | //4、构造结果 |
93 | Map<String, Aggregation> aggregationMap = searchResult.getAggMaps(); | 96 | Map<String, Aggregation> aggregationMap = searchResult.getAggMaps(); |
97 | + List<Integer> addScorePoolIds = this.genAddScorePoolIds(aggregationMap); | ||
94 | List<SortBrand> sortBrands = this.getBrandSortsFromAggregationMap(aggregationMap); | 98 | List<SortBrand> sortBrands = this.getBrandSortsFromAggregationMap(aggregationMap); |
95 | List<Integer> misortIds = this.getMisortIds(sortBrands); | 99 | List<Integer> misortIds = this.getMisortIds(sortBrands); |
96 | List<Integer> brandIds = this.getBrandIds(sortBrands); | 100 | List<Integer> brandIds = this.getBrandIds(sortBrands); |
97 | - return new PagePersonalFactor(misortIds, brandIds, sortBrands); | 101 | + return new PagePersonalFactor(misortIds, brandIds, sortBrands,addScorePoolIds); |
102 | + } | ||
103 | + | ||
104 | + private List<Integer> genAddScorePoolIds(Map<String, Aggregation> aggregationMap) { | ||
105 | + return AggCommonHelper.getIdsFromAggMaps(aggregationMap,"addScorePoolIdsAgg"); | ||
98 | } | 106 | } |
99 | 107 | ||
100 | private List<Integer> getMisortIds(List<SortBrand> sortBrands) { | 108 | private List<Integer> getMisortIds(List<SortBrand> sortBrands) { |
@@ -136,59 +144,80 @@ public class QueryPageFactorBaseService extends AbstractCacheComponent<PagePerso | @@ -136,59 +144,80 @@ public class QueryPageFactorBaseService extends AbstractCacheComponent<PagePerso | ||
136 | return middleSortAggBuilder; | 144 | return middleSortAggBuilder; |
137 | } | 145 | } |
138 | 146 | ||
139 | - private List<SortBrand> getBrandSortsFromAggregationMap(Map<String, Aggregation> aggregationMap) { | ||
140 | - Map<Integer, List<Integer>> brand2MiSortIdsMap = this.getValueFromAggregationMap(aggregationMap, "sortBrandBrandIdAgg", "sortBrandMiddleSortAgg"); | ||
141 | - List<SortBrand> pageBrandSorts = new ArrayList<>(); | ||
142 | - for (Map.Entry<Integer, List<Integer>> entry : brand2MiSortIdsMap.entrySet()) { | ||
143 | - Integer brandId = entry.getKey(); | ||
144 | - List<Integer> misorts = entry.getValue(); | ||
145 | - for (Integer misort : misorts) { | ||
146 | - pageBrandSorts.add(new SortBrand(misort, brandId)); | ||
147 | - } | ||
148 | - } | ||
149 | - return pageBrandSorts; | ||
150 | - } | ||
151 | - | ||
152 | /** | 147 | /** |
153 | - * 从聚合结果中获取参数,仅支持二层聚合 | 148 | + * skn-商品池 |
154 | * | 149 | * |
155 | - * @param aggregationMap | ||
156 | - * @param firstAggName | ||
157 | - * @param secondAggName | ||
158 | * @return | 150 | * @return |
159 | */ | 151 | */ |
160 | - private Map<Integer, List<Integer>> getValueFromAggregationMap(Map<String, Aggregation> aggregationMap, String firstAggName, String secondAggName) { | ||
161 | - Map<Integer, List<Integer>> aggResultMap = new HashMap<>(); | ||
162 | - if (!aggregationMap.containsKey(firstAggName)) { | ||
163 | - return aggResultMap; | ||
164 | - } | ||
165 | - MultiBucketsAggregation firstAggregation = (MultiBucketsAggregation) aggregationMap.get(firstAggName); | ||
166 | - Iterator<? extends MultiBucketsAggregation.Bucket> firstAggregationIterator = firstAggregation.getBuckets().iterator(); | ||
167 | - while (firstAggregationIterator.hasNext()) { | ||
168 | - MultiBucketsAggregation.Bucket firstAggregationBucket = firstAggregationIterator.next(); | ||
169 | - Integer firstAggregationBucketKey = Integer.valueOf(firstAggregationBucket.getKeyAsString()); | ||
170 | - Map<String, Aggregation> secondAggregationMap = firstAggregationBucket.getAggregations().asMap(); | ||
171 | - if (secondAggregationMap == null || !secondAggregationMap.containsKey(secondAggName)) { | ||
172 | - continue; | ||
173 | - } | ||
174 | - List<Integer> secondAggregationBucketKeys = this.getAggValuesFromMultiBucketsAggregation((MultiBucketsAggregation) secondAggregationMap.get(secondAggName)); | ||
175 | - aggResultMap.put(firstAggregationBucketKey, secondAggregationBucketKeys); | ||
176 | - } | ||
177 | - return aggResultMap; | 152 | + private TermsAggregationBuilder addScorePoolIdsBuilder() { |
153 | + TermsAggregationBuilder addScorePoolIdsAggBuilder = AggregationBuilders.terms("addScorePoolIdsAgg").field(ProductIndexEsField.toAddScorePoolIds).size(20); | ||
154 | + return addScorePoolIdsAggBuilder; | ||
178 | } | 155 | } |
179 | 156 | ||
180 | - private List<Integer> getAggValuesFromMultiBucketsAggregation(MultiBucketsAggregation aggregation) { | ||
181 | - List<Integer> results = new ArrayList<>(); | ||
182 | - if (aggregation == null) { | ||
183 | - return results; | ||
184 | - } | ||
185 | - Iterator<? extends MultiBucketsAggregation.Bucket> bucketsIterator = aggregation.getBuckets().iterator(); | ||
186 | - while (bucketsIterator.hasNext()) { | ||
187 | - MultiBucketsAggregation.Bucket bucket = bucketsIterator.next(); | ||
188 | - Integer value = Integer.valueOf(bucket.getKeyAsString()); | ||
189 | - results.add(value); | 157 | + private List<SortBrand> getBrandSortsFromAggregationMap(Map<String, Aggregation> aggregationMap) { |
158 | + List<AggKeyCountTwoLevel> results = AggCommonHelper.getAggKeyCountTwoLevelList(aggregationMap,"sortBrandBrandIdAgg","sortBrandMiddleSortAgg"); | ||
159 | + List<SortBrand> pageBrandSorts = new ArrayList<>(); | ||
160 | + for (AggKeyCountTwoLevel aggKeyCountTwoLevel : results) { | ||
161 | + Integer brandId = aggKeyCountTwoLevel.getFirstAggKeyCount().getKey(); | ||
162 | + List<AggKeyCount> misortInfos = aggKeyCountTwoLevel.getSecondAggKeyCountList(); | ||
163 | + for (AggKeyCount misortInfo : misortInfos) { | ||
164 | + pageBrandSorts.add(new SortBrand(misortInfo.getKey(), brandId)); | ||
190 | } | 165 | } |
191 | - return results; | ||
192 | } | 166 | } |
167 | + return pageBrandSorts; | ||
168 | + | ||
169 | +// Map<Integer, List<Integer>> brand2MiSortIdsMap = this.getValueFromAggregationMap(aggregationMap, "sortBrandBrandIdAgg", "sortBrandMiddleSortAgg"); | ||
170 | +// List<SortBrand> pageBrandSorts = new ArrayList<>(); | ||
171 | +// for (Map.Entry<Integer, List<Integer>> entry : brand2MiSortIdsMap.entrySet()) { | ||
172 | +// Integer brandId = entry.getKey(); | ||
173 | +// List<Integer> misorts = entry.getValue(); | ||
174 | +// for (Integer misort : misorts) { | ||
175 | +// pageBrandSorts.add(new SortBrand(misort, brandId)); | ||
176 | +// } | ||
177 | +// } | ||
178 | +// return pageBrandSorts; | ||
179 | + } | ||
180 | + | ||
181 | +// /** | ||
182 | +// * 从聚合结果中获取参数,仅支持二层聚合 | ||
183 | +// * | ||
184 | +// * @param aggregationMap | ||
185 | +// * @param firstAggName | ||
186 | +// * @param secondAggName | ||
187 | +// * @return | ||
188 | +// */ | ||
189 | +// private Map<Integer, List<Integer>> getValueFromAggregationMap(Map<String, Aggregation> aggregationMap, String firstAggName, String secondAggName) { | ||
190 | +// Map<Integer, List<Integer>> aggResultMap = new HashMap<>(); | ||
191 | +// if (!aggregationMap.containsKey(firstAggName)) { | ||
192 | +// return aggResultMap; | ||
193 | +// } | ||
194 | +// MultiBucketsAggregation firstAggregation = (MultiBucketsAggregation) aggregationMap.get(firstAggName); | ||
195 | +// Iterator<? extends MultiBucketsAggregation.Bucket> firstAggregationIterator = firstAggregation.getBuckets().iterator(); | ||
196 | +// while (firstAggregationIterator.hasNext()) { | ||
197 | +// MultiBucketsAggregation.Bucket firstAggregationBucket = firstAggregationIterator.next(); | ||
198 | +// Integer firstAggregationBucketKey = Integer.valueOf(firstAggregationBucket.getKeyAsString()); | ||
199 | +// Map<String, Aggregation> secondAggregationMap = firstAggregationBucket.getAggregations().asMap(); | ||
200 | +// if (secondAggregationMap == null || !secondAggregationMap.containsKey(secondAggName)) { | ||
201 | +// continue; | ||
202 | +// } | ||
203 | +// List<Integer> secondAggregationBucketKeys = this.getAggValuesFromMultiBucketsAggregation((MultiBucketsAggregation) secondAggregationMap.get(secondAggName)); | ||
204 | +// aggResultMap.put(firstAggregationBucketKey, secondAggregationBucketKeys); | ||
205 | +// } | ||
206 | +// return aggResultMap; | ||
207 | +// } | ||
208 | +// | ||
209 | +// private List<Integer> getAggValuesFromMultiBucketsAggregation(MultiBucketsAggregation aggregation) { | ||
210 | +// List<Integer> results = new ArrayList<>(); | ||
211 | +// if (aggregation == null) { | ||
212 | +// return results; | ||
213 | +// } | ||
214 | +// Iterator<? extends MultiBucketsAggregation.Bucket> bucketsIterator = aggregation.getBuckets().iterator(); | ||
215 | +// while (bucketsIterator.hasNext()) { | ||
216 | +// MultiBucketsAggregation.Bucket bucket = bucketsIterator.next(); | ||
217 | +// Integer value = Integer.valueOf(bucket.getKeyAsString()); | ||
218 | +// results.add(value); | ||
219 | +// } | ||
220 | +// return results; | ||
221 | +// } | ||
193 | 222 | ||
194 | } | 223 | } |
@@ -3,17 +3,20 @@ package com.yoho.search.service.recall.beans; | @@ -3,17 +3,20 @@ package com.yoho.search.service.recall.beans; | ||
3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
4 | import com.yoho.search.core.personalized.models.SortBrand; | 4 | import com.yoho.search.core.personalized.models.SortBrand; |
5 | import com.yoho.search.dal.model.CsRecallConfigSortPrice; | 5 | import com.yoho.search.dal.model.CsRecallConfigSortPrice; |
6 | -import com.yoho.search.models.recall.SortBrandSknCount; | ||
7 | import com.yoho.search.models.recall.PagePersonalFactor; | 6 | import com.yoho.search.models.recall.PagePersonalFactor; |
7 | +import com.yoho.search.models.recall.SortBrandSknCount; | ||
8 | import com.yoho.search.models.recall.UserRecallRequest; | 8 | import com.yoho.search.models.recall.UserRecallRequest; |
9 | import com.yoho.search.service.recall.reloadable.*; | 9 | import com.yoho.search.service.recall.reloadable.*; |
10 | import com.yoho.search.service.recall.strategy.SortBrandType; | 10 | import com.yoho.search.service.recall.strategy.SortBrandType; |
11 | import com.yoho.search.service.recall.strategy.StrategyEnum; | 11 | import com.yoho.search.service.recall.strategy.StrategyEnum; |
12 | +import org.apache.commons.collections.CollectionUtils; | ||
12 | import org.slf4j.Logger; | 13 | import org.slf4j.Logger; |
13 | import org.slf4j.LoggerFactory; | 14 | import org.slf4j.LoggerFactory; |
14 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
15 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
16 | 17 | ||
18 | +import java.util.ArrayList; | ||
19 | +import java.util.Collections; | ||
17 | import java.util.List; | 20 | import java.util.List; |
18 | import java.util.Set; | 21 | import java.util.Set; |
19 | 22 | ||
@@ -143,4 +146,27 @@ public class RecallConfigService { | @@ -143,4 +146,27 @@ public class RecallConfigService { | ||
143 | return configSortPriceService.randomConfigSortPrice(pageFactor, count); | 146 | return configSortPriceService.randomConfigSortPrice(pageFactor, count); |
144 | } | 147 | } |
145 | 148 | ||
149 | + /** | ||
150 | + * 随机获取商品池 | ||
151 | + * | ||
152 | + * @param pageFactor | ||
153 | + * @param count | ||
154 | + * @return | ||
155 | + */ | ||
156 | + public List<Integer> randomDirectTrainSknPoolIds(PagePersonalFactor pageFactor, int count) { | ||
157 | + if (count <= 0 || CollectionUtils.isEmpty(pageFactor.getAddScorePoolIds())){ | ||
158 | + return new ArrayList<>(); | ||
159 | + } | ||
160 | + List<Integer> copyList = new ArrayList<>(pageFactor.getAddScorePoolIds()); | ||
161 | + Collections.shuffle(copyList); | ||
162 | + List<Integer> results = new ArrayList<>(); | ||
163 | + for (Integer sknPoolIds : copyList) { | ||
164 | + if (results.size() >= count) { | ||
165 | + break; | ||
166 | + } | ||
167 | + results.add(sknPoolIds); | ||
168 | + } | ||
169 | + return results; | ||
170 | + } | ||
171 | + | ||
146 | } | 172 | } |
@@ -23,6 +23,8 @@ public class CommonRecallRequestBuilder { | @@ -23,6 +23,8 @@ public class CommonRecallRequestBuilder { | ||
23 | @Autowired | 23 | @Autowired |
24 | private DirectTrainBrandRequestsBuiler directTrainBrandRequestsBuiler; | 24 | private DirectTrainBrandRequestsBuiler directTrainBrandRequestsBuiler; |
25 | @Autowired | 25 | @Autowired |
26 | + private DirectTrainSknPoolRequestsBuilder directTrainSknPoolRequestsBuilder; | ||
27 | + @Autowired | ||
26 | private DirectTrainSortPriceRequestsBuilder directTrainSortPriceRequestsBuilder; | 28 | private DirectTrainSortPriceRequestsBuilder directTrainSortPriceRequestsBuilder; |
27 | 29 | ||
28 | /** | 30 | /** |
@@ -49,10 +51,11 @@ public class CommonRecallRequestBuilder { | @@ -49,10 +51,11 @@ public class CommonRecallRequestBuilder { | ||
49 | requests.addAll(this.buildUfoDirectTrainRequest(userRecallRequest)); | 51 | requests.addAll(this.buildUfoDirectTrainRequest(userRecallRequest)); |
50 | //6.3) 直通车-品牌召回 | 52 | //6.3) 直通车-品牌召回 |
51 | requests.addAll(directTrainBrandRequestsBuiler.buildDirectTrainBrandRequests(userRecallRequest, pagePersonalFactor)); | 53 | requests.addAll(directTrainBrandRequestsBuiler.buildDirectTrainBrandRequests(userRecallRequest, pagePersonalFactor)); |
52 | - //6.4) 直通车-品类价格带 | 54 | + //6.4) 直通车-商品池 |
55 | + requests.addAll(directTrainSknPoolRequestsBuilder.buildDirectTrainSknPoolRequests(userRecallRequest, pagePersonalFactor)); | ||
56 | + //6.5) 直通车-品类价格带 | ||
53 | requests.addAll(directTrainSortPriceRequestsBuilder.buildDirectTrainSortPriceRequests(userRecallRequest, pagePersonalFactor)); | 57 | requests.addAll(directTrainSortPriceRequestsBuilder.buildDirectTrainSortPriceRequests(userRecallRequest, pagePersonalFactor)); |
54 | 58 | ||
55 | - | ||
56 | //7、 随机召回 | 59 | //7、 随机召回 |
57 | requests.addAll(this.buildCommonRandomStrategy(userRecallRequest)); | 60 | requests.addAll(this.buildCommonRandomStrategy(userRecallRequest)); |
58 | //8、 页面的兜底召回 | 61 | //8、 页面的兜底召回 |
1 | +package com.yoho.search.service.recall.beans.requests; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSON; | ||
4 | +import com.yoho.search.models.recall.PagePersonalFactor; | ||
5 | +import com.yoho.search.models.recall.RecallRequest; | ||
6 | +import com.yoho.search.models.recall.UserRecallRequest; | ||
7 | +import com.yoho.search.service.recall.beans.RecallConfigService; | ||
8 | +import com.yoho.search.service.recall.helper.RecallConfigConstants; | ||
9 | +import com.yoho.search.service.recall.strategy.IStrategy; | ||
10 | +import com.yoho.search.service.recall.strategy.StrategyEnum; | ||
11 | +import com.yoho.search.service.recall.strategy.impls.DirectTrainSknPoolStrategy; | ||
12 | +import org.apache.commons.collections.CollectionUtils; | ||
13 | +import org.slf4j.Logger; | ||
14 | +import org.slf4j.LoggerFactory; | ||
15 | +import org.springframework.beans.factory.annotation.Autowired; | ||
16 | +import org.springframework.stereotype.Component; | ||
17 | + | ||
18 | +import java.util.ArrayList; | ||
19 | +import java.util.Collections; | ||
20 | +import java.util.List; | ||
21 | + | ||
22 | +@Component | ||
23 | +public class DirectTrainSknPoolRequestsBuilder { | ||
24 | + | ||
25 | + private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL"); | ||
26 | + | ||
27 | + @Autowired | ||
28 | + private RecallConfigService recallConfigService; | ||
29 | + | ||
30 | + /** | ||
31 | + * 构造直通车-[品类价格带]的召回请求 | ||
32 | + * | ||
33 | + * @param userRecallRequest | ||
34 | + * @return | ||
35 | + */ | ||
36 | + public List<RecallRequest> buildDirectTrainSknPoolRequests(UserRecallRequest userRecallRequest, PagePersonalFactor pageFactor) { | ||
37 | + int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.DIRECT_TRAIN_SKN_POOL, 0); | ||
38 | + if (size == 0) { | ||
39 | + return Collections.emptyList(); | ||
40 | + } | ||
41 | + List<Integer> randomDirectTrainSknPoolIdList = recallConfigService.randomDirectTrainSknPoolIds(pageFactor, size); | ||
42 | + if (CollectionUtils.isEmpty(randomDirectTrainSknPoolIdList)) { | ||
43 | + return Collections.emptyList(); | ||
44 | + } | ||
45 | + RECALL_NEW_LOGGER.info("directTrainSknPoolRequests is[{}]", JSON.toJSONString(randomDirectTrainSknPoolIdList)); | ||
46 | + List<RecallRequest> requests = new ArrayList<>(); | ||
47 | + int productSize = RecallConfigConstants.DEFAULT_DIRECT_TRAIN_PRODUCT_SIZE; | ||
48 | + for (Integer sknPoolId : randomDirectTrainSknPoolIdList) { | ||
49 | + IStrategy strategy = new DirectTrainSknPoolStrategy(sknPoolId, productSize); | ||
50 | + requests.add(new RecallRequest(userRecallRequest.getParamQueryFilter(), strategy)); | ||
51 | + } | ||
52 | + return requests; | ||
53 | + } | ||
54 | +} |
@@ -34,6 +34,7 @@ public class DirectTrainSortPriceRequestsBuilder { | @@ -34,6 +34,7 @@ public class DirectTrainSortPriceRequestsBuilder { | ||
34 | * @param userRecallRequest | 34 | * @param userRecallRequest |
35 | * @return | 35 | * @return |
36 | */ | 36 | */ |
37 | + | ||
37 | public List<RecallRequest> buildDirectTrainSortPriceRequests(UserRecallRequest userRecallRequest, PagePersonalFactor pageFactor) { | 38 | public List<RecallRequest> buildDirectTrainSortPriceRequests(UserRecallRequest userRecallRequest, PagePersonalFactor pageFactor) { |
38 | int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.DIRECT_TRAIN_SORT_PRICE, 0); | 39 | int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.DIRECT_TRAIN_SORT_PRICE, 0); |
39 | if (size == 0) { | 40 | if (size == 0) { |
@@ -15,13 +15,13 @@ import org.elasticsearch.search.sort.SortBuilder; | @@ -15,13 +15,13 @@ import org.elasticsearch.search.sort.SortBuilder; | ||
15 | public class DirectTrainSknPoolStrategy implements IStrategy { | 15 | public class DirectTrainSknPoolStrategy implements IStrategy { |
16 | 16 | ||
17 | private Integer poolId; | 17 | private Integer poolId; |
18 | - private int size; | ||
19 | - | ||
20 | public DirectTrainSknPoolStrategy(Integer poolId, int size){ | 18 | public DirectTrainSknPoolStrategy(Integer poolId, int size){ |
21 | this.poolId = poolId; | 19 | this.poolId = poolId; |
22 | this.size = size; | 20 | this.size = size; |
23 | } | 21 | } |
24 | 22 | ||
23 | + private int size; | ||
24 | + | ||
25 | @Override | 25 | @Override |
26 | public StrategyEnum strategtEnum() { | 26 | public StrategyEnum strategtEnum() { |
27 | return StrategyEnum.DIRECT_TRAIN_SKN_POOL; | 27 | return StrategyEnum.DIRECT_TRAIN_SKN_POOL; |
-
Please register or login to post a comment