SearchDynamicConfigService.java
6.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
package com.yoho.search.service.base;
import com.yoho.core.config.ConfigReader;
import com.yoho.search.common.downgrade.persional.PersionalRateLimit;
import com.yoho.search.common.downgrade.persional.PersionalRateLimitConfig;
import com.yoho.search.recall.scene.constants.RecallCommonConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class SearchDynamicConfigService {
private static final Logger logger = LoggerFactory.getLogger(SearchDynamicConfigService.class);
@Autowired
private ConfigReader configReader;
/**
* 是否开启个性化
*
* @return
*/
public boolean openPersonalized() {
return configReader.getBoolean("search.degrade.open.personalized", true);
}
/**
* 搜索结果是否包含全球购
*
* @return
*/
public boolean containglobal() {
return configReader.getBoolean("search.degrade.open.containglobal", true);
}
/**
* 是否返回变价计划
*
* @return
*/
public boolean pricePlanOpen() {
return configReader.getBoolean("search.price.plan.open", true);
}
/**
* 频道降分是否打开
*
* @return
*/
public boolean isDeScorePhysicalChannelOpen() {
return configReader.getBoolean("search.degrade.descore.physicalchannel.open", true);
}
/**
* 频道降分权重
*
* @return
*/
public double getDeScorePhysicalChannelWeight() {
return configReader.getDouble("search.degrade.descore.physicalchannel.value", 0.6);
}
/**
* 是否打开搜索无结果或结果太少时的搜索提示功能
*
* @return
*/
public boolean isSearchSuggestionTipsOpen() {
return configReader.getBoolean("search.suggestion.tips.open", true);
}
/**
* 关于API查看动态参数值
*/
public String getDynamicParameterValue(String key) {
return configReader.getString(key, "DEFAULT");
}
/**
* 新品到着页的根据首次上架时间衰减函数规则值
*/
public String getNewArrivalPageDecayRuleValue() {
return configReader.getString("search.function.score.new_arrival_page_decay_rule", "4,1");
}
/**
* 非新品到着页的根据首次上架时间衰减函数规则值
*/
public String getOtherPageDecayRuleValue() {
return configReader.getString("search.function.score.other_page_decay_rule", "30,7");
}
/**
* 商品详情页-店铺外推荐同品类的比例
*/
public int getSearchLikeNotInShopSameSortPercent() {
return configReader.getInt("search.searchlike.not_in_shop.same_sort_percent", 60);
}
/**
* 个性化限流配置
*/
public PersionalRateLimitConfig getPersionalRateLimitConfig(String rateLimitName, PersionalRateLimit persionalRateLimit) {
try {
String zkConfigKey = "search.persional.rateLimit" + rateLimitName.replaceAll("/", ".");
PersionalRateLimitConfig defalut = new PersionalRateLimitConfig(persionalRateLimit);
String zkConfigValue = configReader.getString(zkConfigKey, defalut.toZkValue());
return new PersionalRateLimitConfig(zkConfigValue);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new PersionalRateLimitConfig(200, 10);
}
}
/**
* 个性化限流开关【双11打开】
*/
public boolean isPersionalRateLimitOpen() {
return configReader.getBoolean("search.persional.rateLimit.open", true);
}
/**
* 使用新的的召回策略
*
* @return
*/
public boolean searchPersionalNewStrategyOpen() {
return configReader.getBoolean("search.persional.newstrategy.open", false);
}
/**
* 促销页使用新的的召回策略
*
* @return
*/
public boolean searchPersionalNewStrategyPromotionOpen() {
return configReader.getBoolean("search.persional.newstrategy.promotion.open", true);
}
/**
* 新的的召回策略-第一页是否缓存
*
* @return
*/
public boolean searchPersionalNewStrategyFirstPageCacheOpen() {
return configReader.getBoolean("search.persional.newstrategy.first_page_cache.open", false);
}
/**
* 新的的召回策略-兜底策略是否参与评分
*
* @return
*/
public boolean searchPersionalNewStrategyCommonJoinScoreOpen() {
return configReader.getBoolean("search.persional.newstrategy.common.join_score.open", false);
}
/**
* 新的的召回策略-实时的品牌品类
*
* @return
*/
public int maxRealTimeSortBrandCount() {
return configReader.getInt("search.persional.newstrategy.realtime.max_sort_brand.count", RecallCommonConstants.maxRealTimeSortBrandCount);
}
/**
* 新的的召回策略-基于向量的品牌品类
*
* @return
*/
public int maxVectorSortBrandCount() {
return configReader.getInt("search.persional.newstrategy.vector.max_sort_brand.count", RecallCommonConstants.maxVectorSortBrandCount);
}
/**
* 新的的召回策略-预测的品牌品类
*
* @return
*/
public int maxForecastSortBrandCount() {
return configReader.getInt("search.persional.newstrategy.forecast.max_sort_brand.count", RecallCommonConstants.maxForecastSortBrandCount);
}
/**
* 新的的召回策略-最多预测的品牌品类
*
* @return
*/
public int directTrainIndexInterval() {
return configReader.getInt("search.persional.newstrategy.directtrain.index.interval",4);
}
/**
* 新的的召回策略-召回来后是否再次进行品类品牌的平衡
*
* @return
*/
public boolean searchPersionalNewStrategySortBrandBalance() {
return configReader.getBoolean("search.persional.newstrategy.sort_brand_balance.open", false);
}
/**
* 使用性能高的召回场景【双11打开】
*
* @return
*/
public boolean searchPersionalPerfamanceStrategyOpen() {
return configReader.getBoolean("search.persional.performancestrategy.open", false);
}
/**
* 相关推荐否使用个性化-【双11关闭】
*/
public boolean isRecommendPersionalOpen() {
return configReader.getBoolean("search.persional.recommend.open", true);
}
/**
* 找相似是否使用bigdatasimilarskn
*/
public boolean isSearchLikeSimilarSknOpen() {
return configReader.getBoolean("search.searchlike.similarskn", true);
}
/**
* 超时日志是否打开
*/
public boolean isControllerCostLogOpen() {
return configReader.getBoolean("search.controller.cost.log.open", true);
}
/**
* 推荐品牌是否要使用大数据的推荐
* @return
*/
public boolean isRecommendBrandUserPersonalOpen() {
return configReader.getBoolean("search.recommendbrand.userPersonal.open", false);
}
/**
* 奇数的uid使用AB-TEST
* @return
*/
public boolean isAbTestUser(int uid) {
boolean abTestOpen = configReader.getBoolean("search.persional.abTest.open", false);
if(!abTestOpen){
return true;
}
if(uid%2==1){
return true;
}
return false;
}
}