使用ProductIndexEsField重构constructFilterBuilder
Showing
1 changed file
with
59 additions
and
64 deletions
@@ -3,12 +3,14 @@ package com.yoho.search.service.service.helper; | @@ -3,12 +3,14 @@ package com.yoho.search.service.service.helper; | ||
3 | import com.yoho.search.base.utils.ConvertUtils; | 3 | import com.yoho.search.base.utils.ConvertUtils; |
4 | import com.yoho.search.base.utils.DateUtil; | 4 | import com.yoho.search.base.utils.DateUtil; |
5 | import com.yoho.search.base.utils.ISearchConstants; | 5 | import com.yoho.search.base.utils.ISearchConstants; |
6 | +import com.yoho.search.base.utils.ProductIndexEsField; | ||
6 | import com.yoho.search.core.es.model.SearchParam; | 7 | import com.yoho.search.core.es.model.SearchParam; |
7 | import com.yoho.search.core.es.model.SearchResult; | 8 | import com.yoho.search.core.es.model.SearchResult; |
8 | import com.yoho.search.service.service.SearchCommonService; | 9 | import com.yoho.search.service.service.SearchCommonService; |
9 | import com.yoho.search.service.service.SearchDynamicConfigService; | 10 | import com.yoho.search.service.service.SearchDynamicConfigService; |
10 | import com.yoho.search.service.service.SearchKeyWordService; | 11 | import com.yoho.search.service.service.SearchKeyWordService; |
11 | import com.yoho.search.service.utils.SearchRequestParams; | 12 | import com.yoho.search.service.utils.SearchRequestParams; |
13 | + | ||
12 | import org.apache.commons.lang.StringUtils; | 14 | import org.apache.commons.lang.StringUtils; |
13 | import org.elasticsearch.index.query.*; | 15 | import org.elasticsearch.index.query.*; |
14 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
@@ -27,7 +29,6 @@ public class SearchServiceHelper { | @@ -27,7 +29,6 @@ public class SearchServiceHelper { | ||
27 | 29 | ||
28 | @Autowired | 30 | @Autowired |
29 | private SearchCommonHelper searchCommonHelper; | 31 | private SearchCommonHelper searchCommonHelper; |
30 | - | ||
31 | @Autowired | 32 | @Autowired |
32 | private SearchKeyWordService searchKeyWordService; | 33 | private SearchKeyWordService searchKeyWordService; |
33 | @Autowired | 34 | @Autowired |
@@ -61,7 +62,7 @@ public class SearchServiceHelper { | @@ -61,7 +62,7 @@ public class SearchServiceHelper { | ||
61 | 62 | ||
62 | // 3.如果查询的是skn,则直接走productSkn_ansj这个字段 | 63 | // 3.如果查询的是skn,则直接走productSkn_ansj这个字段 |
63 | if (searchCommonHelper.isQuerySkn(keyword)) { | 64 | if (searchCommonHelper.isQuerySkn(keyword)) { |
64 | - queryBuilder.field("productSkn.productSkn_ansj"); | 65 | + queryBuilder.field(ProductIndexEsField.productSkn_productSkn_ansj); |
65 | queryBuilder.operator(MatchQueryBuilder.Operator.OR); | 66 | queryBuilder.operator(MatchQueryBuilder.Operator.OR); |
66 | return queryBuilder; | 67 | return queryBuilder; |
67 | } | 68 | } |
@@ -108,7 +109,7 @@ public class SearchServiceHelper { | @@ -108,7 +109,7 @@ public class SearchServiceHelper { | ||
108 | 109 | ||
109 | // 3.如果查询的是skn,则直接走productSkn_ansj这个字段 | 110 | // 3.如果查询的是skn,则直接走productSkn_ansj这个字段 |
110 | if (searchCommonHelper.isQuerySkn(keyword)) { | 111 | if (searchCommonHelper.isQuerySkn(keyword)) { |
111 | - queryBuilder.field("productSkn.productSkn_ansj"); | 112 | + queryBuilder.field(ProductIndexEsField.productSkn_productSkn_ansj); |
112 | queryBuilder.operator(MatchQueryBuilder.Operator.OR); | 113 | queryBuilder.operator(MatchQueryBuilder.Operator.OR); |
113 | return queryBuilder; | 114 | return queryBuilder; |
114 | } | 115 | } |
@@ -196,63 +197,56 @@ public class SearchServiceHelper { | @@ -196,63 +197,56 @@ public class SearchServiceHelper { | ||
196 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_BRAND) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_BRAND)) | 197 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_BRAND) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_BRAND)) |
197 | && !SearchRequestParams.PARAM_SEARCH_BRAND.equals(filterParamName)) { | 198 | && !SearchRequestParams.PARAM_SEARCH_BRAND.equals(filterParamName)) { |
198 | int[] brandids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_BRAND), ","); | 199 | int[] brandids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_BRAND), ","); |
199 | - boolFilter.must(QueryBuilders.termsQuery("brandId", brandids)); | 200 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.brandId, brandids)); |
200 | } | 201 | } |
201 | 202 | ||
202 | - // 全局降分品牌过滤 | ||
203 | - // if | ||
204 | - // ("Y".equals(paramMap.get(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND))) | ||
205 | - // { | ||
206 | - // boolFilter.mustNot(QueryBuilders.termQuery("isForbiddenSortBrand", | ||
207 | - // 1)); | ||
208 | - // } | ||
209 | if ("Y".equals(paramMap.get(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND)) && StringUtils.isNotBlank(paramMap.get("pageId"))) { | 203 | if ("Y".equals(paramMap.get(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND)) && StringUtils.isNotBlank(paramMap.get("pageId"))) { |
210 | - boolFilter.mustNot(QueryBuilders.termQuery("forbiddenPageIds", paramMap.get("pageId"))); | 204 | + boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.forbiddenPageIds, paramMap.get("pageId"))); |
211 | } | 205 | } |
212 | 206 | ||
213 | // 店铺 | 207 | // 店铺 |
214 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SHOP) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOP)) | 208 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SHOP) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOP)) |
215 | && !SearchRequestParams.PARAM_SEARCH_SHOP.equals(filterParamName)) { | 209 | && !SearchRequestParams.PARAM_SEARCH_SHOP.equals(filterParamName)) { |
216 | int[] shopids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOP), ","); | 210 | int[] shopids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOP), ","); |
217 | - boolFilter.must(QueryBuilders.termsQuery("shopId", shopids)); | 211 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.shopId, shopids)); |
218 | } | 212 | } |
219 | // 大分类 | 213 | // 大分类 |
220 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_MAXSORT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_MAXSORT)) | 214 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_MAXSORT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_MAXSORT)) |
221 | && !SearchRequestParams.PARAM_SEARCH_MAXSORT.equals(filterParamName)) { | 215 | && !SearchRequestParams.PARAM_SEARCH_MAXSORT.equals(filterParamName)) { |
222 | int[] maxsortids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_MAXSORT), ","); | 216 | int[] maxsortids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_MAXSORT), ","); |
223 | - boolFilter.must(QueryBuilders.termsQuery("maxSortId", maxsortids)); | 217 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.maxSortId, maxsortids)); |
224 | } | 218 | } |
225 | // 中类 | 219 | // 中类 |
226 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_MIDDLESORT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_MIDDLESORT)) | 220 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_MIDDLESORT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_MIDDLESORT)) |
227 | && !SearchRequestParams.PARAM_SEARCH_MAXSORT.equals(filterParamName)) { | 221 | && !SearchRequestParams.PARAM_SEARCH_MAXSORT.equals(filterParamName)) { |
228 | int[] middlesortids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_MIDDLESORT), ","); | 222 | int[] middlesortids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_MIDDLESORT), ","); |
229 | - boolFilter.must(QueryBuilders.termsQuery("middleSortId", middlesortids)); | 223 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.middleSortId, middlesortids)); |
230 | } | 224 | } |
231 | // 小类 | 225 | // 小类 |
232 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SMALLSORT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SMALLSORT))) { | 226 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SMALLSORT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SMALLSORT))) { |
233 | int[] smallsortids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_SMALLSORT), ","); | 227 | int[] smallsortids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_SMALLSORT), ","); |
234 | - boolFilter.must(QueryBuilders.termsQuery("smallSortId", smallsortids)); | 228 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.smallSortId, smallsortids)); |
235 | } | 229 | } |
236 | // 大中小分类 | 230 | // 大中小分类 |
237 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_COMMONSORT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_COMMONSORT))) { | 231 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_COMMONSORT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_COMMONSORT))) { |
238 | int[] commonSortIds = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_COMMONSORT), ","); | 232 | int[] commonSortIds = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_COMMONSORT), ","); |
239 | BoolQueryBuilder commonSortIdFilter = QueryBuilders.boolQuery(); | 233 | BoolQueryBuilder commonSortIdFilter = QueryBuilders.boolQuery(); |
240 | - commonSortIdFilter.should(QueryBuilders.termsQuery("maxSortId", commonSortIds)); | ||
241 | - commonSortIdFilter.should(QueryBuilders.termsQuery("middleSortId", commonSortIds)); | ||
242 | - commonSortIdFilter.should(QueryBuilders.termsQuery("smallSortId", commonSortIds)); | 234 | + commonSortIdFilter.should(QueryBuilders.termsQuery(ProductIndexEsField.maxSortId, commonSortIds)); |
235 | + commonSortIdFilter.should(QueryBuilders.termsQuery(ProductIndexEsField.middleSortId, commonSortIds)); | ||
236 | + commonSortIdFilter.should(QueryBuilders.termsQuery(ProductIndexEsField.smallSortId, commonSortIds)); | ||
243 | boolFilter.must(commonSortIdFilter); | 237 | boolFilter.must(commonSortIdFilter); |
244 | } | 238 | } |
245 | // 颜色 | 239 | // 颜色 |
246 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_COLOR) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_COLOR)) | 240 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_COLOR) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_COLOR)) |
247 | && !SearchRequestParams.PARAM_SEARCH_COLOR.equals(filterParamName)) { | 241 | && !SearchRequestParams.PARAM_SEARCH_COLOR.equals(filterParamName)) { |
248 | int[] colorids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_COLOR), ","); | 242 | int[] colorids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_COLOR), ","); |
249 | - boolFilter.must(QueryBuilders.termsQuery("colorIds", colorids)); | 243 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.colorIds, colorids)); |
250 | } | 244 | } |
251 | // 尺码 | 245 | // 尺码 |
252 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SIZE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SIZE)) | 246 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SIZE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SIZE)) |
253 | && !SearchRequestParams.PARAM_SEARCH_SIZE.equals(filterParamName)) { | 247 | && !SearchRequestParams.PARAM_SEARCH_SIZE.equals(filterParamName)) { |
254 | int[] sizeids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_SIZE), ","); | 248 | int[] sizeids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_SIZE), ","); |
255 | - boolFilter.must(QueryBuilders.termsQuery("sizeIds", sizeids)); | 249 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.sizeIds, sizeids)); |
256 | } | 250 | } |
257 | // 销售价格 | 251 | // 销售价格 |
258 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_PRICE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_PRICE)) | 252 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_PRICE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_PRICE)) |
@@ -263,34 +257,33 @@ public class SearchServiceHelper { | @@ -263,34 +257,33 @@ public class SearchServiceHelper { | ||
263 | } | 257 | } |
264 | double begin = Double.parseDouble(prices[0]); | 258 | double begin = Double.parseDouble(prices[0]); |
265 | double end = Double.parseDouble(prices[1]); | 259 | double end = Double.parseDouble(prices[1]); |
266 | - boolFilter.must(QueryBuilders.rangeQuery("salesPrice").gte(begin).lte(end)); | 260 | + boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.salesPrice).gte(begin).lte(end)); |
267 | } | 261 | } |
268 | // 性别 | 262 | // 性别 |
269 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_GENDER) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER)) | 263 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_GENDER) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER)) |
270 | && !SearchRequestParams.PARAM_SEARCH_GENDER.equals(filterParamName)) { | 264 | && !SearchRequestParams.PARAM_SEARCH_GENDER.equals(filterParamName)) { |
271 | int[] genders = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER), ","); | 265 | int[] genders = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER), ","); |
272 | - // boolFilter.must(FilterBuilders.termsFilter("gender", genders)); | ||
273 | - boolFilter.must(QueryBuilders.termsQuery("gender", genders)); | 266 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.gender, genders)); |
274 | } | 267 | } |
275 | // 是否特价 | 268 | // 是否特价 |
276 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SPECIALOFFER) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SPECIALOFFER))) { | 269 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SPECIALOFFER) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SPECIALOFFER))) { |
277 | - boolFilter.must(QueryBuilders.termQuery(SearchRequestParams.PARAM_SEARCH_SPECIALOFFER, paramMap.get(SearchRequestParams.PARAM_SEARCH_SPECIALOFFER))); | 270 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.specialoffer, paramMap.get(SearchRequestParams.PARAM_SEARCH_SPECIALOFFER))); |
278 | } | 271 | } |
279 | // 是否打折 | 272 | // 是否打折 |
280 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISDISCOUNT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISDISCOUNT))) { | 273 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISDISCOUNT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISDISCOUNT))) { |
281 | - boolFilter.must(QueryBuilders.termQuery("isDiscount", paramMap.get(SearchRequestParams.PARAM_SEARCH_ISDISCOUNT))); | 274 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isDiscount, paramMap.get(SearchRequestParams.PARAM_SEARCH_ISDISCOUNT))); |
282 | } | 275 | } |
283 | // 是否为学生价 | 276 | // 是否为学生价 |
284 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STUDENTPRICE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STUDENTPRICE))) { | 277 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STUDENTPRICE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STUDENTPRICE))) { |
285 | - boolFilter.must(QueryBuilders.termQuery(SearchRequestParams.PARAM_SEARCH_STUDENTPRICE, paramMap.get(SearchRequestParams.PARAM_SEARCH_STUDENTPRICE))); | 278 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isStudentPrice, paramMap.get(SearchRequestParams.PARAM_SEARCH_STUDENTPRICE))); |
286 | } | 279 | } |
287 | // 是否学生返币 | 280 | // 是否学生返币 |
288 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STUDENTREBATE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STUDENTREBATE))) { | 281 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STUDENTREBATE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STUDENTREBATE))) { |
289 | - boolFilter.must(QueryBuilders.termQuery("isstudentrebate", paramMap.get(SearchRequestParams.PARAM_SEARCH_STUDENTREBATE))); | 282 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isstudentrebate, paramMap.get(SearchRequestParams.PARAM_SEARCH_STUDENTREBATE))); |
290 | } | 283 | } |
291 | // 是否支持分期 | 284 | // 是否支持分期 |
292 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISINSTALMENT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISINSTALMENT))) { | 285 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISINSTALMENT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISINSTALMENT))) { |
293 | - boolFilter.must(QueryBuilders.termQuery(SearchRequestParams.PARAM_SEARCH_ISINSTALMENT, paramMap.get(SearchRequestParams.PARAM_SEARCH_ISINSTALMENT))); | 286 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isInstalment, paramMap.get(SearchRequestParams.PARAM_SEARCH_ISINSTALMENT))); |
294 | } | 287 | } |
295 | // 属性(待研究) | 288 | // 属性(待研究) |
296 | if (!"parameter".equals(filterParamName)) { | 289 | if (!"parameter".equals(filterParamName)) { |
@@ -309,22 +302,22 @@ public class SearchServiceHelper { | @@ -309,22 +302,22 @@ public class SearchServiceHelper { | ||
309 | for (long standard : standards) { | 302 | for (long standard : standards) { |
310 | // boolFilter.must(FilterBuilders.termFilter("standardIds", | 303 | // boolFilter.must(FilterBuilders.termFilter("standardIds", |
311 | // standard)); | 304 | // standard)); |
312 | - boolFilter.must(QueryBuilders.termQuery("standardIds", standard)); | 305 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.standardIds, standard)); |
313 | } | 306 | } |
314 | } | 307 | } |
315 | } | 308 | } |
316 | // 是否在售 | 309 | // 是否在售 |
317 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISSALES) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISSALES))) { | 310 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISSALES) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISSALES))) { |
318 | - boolFilter.must(QueryBuilders.termQuery("isSales", paramMap.get(SearchRequestParams.PARAM_SEARCH_ISSALES))); | 311 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isSales, paramMap.get(SearchRequestParams.PARAM_SEARCH_ISSALES))); |
319 | } | 312 | } |
320 | // 促销标记 | 313 | // 促销标记 |
321 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISPROMOTION) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISPROMOTION))) { | 314 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISPROMOTION) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISPROMOTION))) { |
322 | int[] ispromotions = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISPROMOTION), ","); | 315 | int[] ispromotions = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISPROMOTION), ","); |
323 | - boolFilter.must(QueryBuilders.termsQuery("ispromotion", ispromotions)); | 316 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.ispromotion, ispromotions)); |
324 | } | 317 | } |
325 | // vip折扣类型 | 318 | // vip折扣类型 |
326 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_VIPDISCOUNTTYPE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_VIPDISCOUNTTYPE))) { | 319 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_VIPDISCOUNTTYPE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_VIPDISCOUNTTYPE))) { |
327 | - boolFilter.must(QueryBuilders.termQuery("vipDiscountType", paramMap.get(SearchRequestParams.PARAM_SEARCH_VIPDISCOUNTTYPE))); | 320 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.vipDiscountType, paramMap.get(SearchRequestParams.PARAM_SEARCH_VIPDISCOUNTTYPE))); |
328 | } | 321 | } |
329 | // 促销折扣 | 322 | // 促销折扣 |
330 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_PD) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_PD))) { | 323 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_PD) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_PD))) { |
@@ -334,15 +327,15 @@ public class SearchServiceHelper { | @@ -334,15 +327,15 @@ public class SearchServiceHelper { | ||
334 | } | 327 | } |
335 | double begin = Double.parseDouble(discounts[0]); | 328 | double begin = Double.parseDouble(discounts[0]); |
336 | double end = Double.parseDouble(discounts[1]); | 329 | double end = Double.parseDouble(discounts[1]); |
337 | - boolFilter.must(QueryBuilders.rangeQuery("promotionDiscount").gte(begin).lte(end)); | 330 | + boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.promotionDiscount).gte(begin).lte(end)); |
338 | } | 331 | } |
339 | // 商品属性 1正常商品 2赠品 | 332 | // 商品属性 1正常商品 2赠品 |
340 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE))) { | 333 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE))) { |
341 | - boolFilter.must(QueryBuilders.termQuery("attribute", paramMap.get(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE))); | 334 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.attribute, paramMap.get(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE))); |
342 | } | 335 | } |
343 | // 商品属性 1赠品 2正常商品 | 336 | // 商品属性 1赠品 2正常商品 |
344 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE_NOT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE_NOT))) { | 337 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE_NOT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE_NOT))) { |
345 | - boolFilter.mustNot(QueryBuilders.termQuery("attribute", paramMap.get(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE_NOT))); | 338 | + boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.attribute, paramMap.get(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE_NOT))); |
346 | } | 339 | } |
347 | // 库存 | 340 | // 库存 |
348 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STOCKNUM) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STOCKNUM))) { | 341 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STOCKNUM) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STOCKNUM))) { |
@@ -350,64 +343,65 @@ public class SearchServiceHelper { | @@ -350,64 +343,65 @@ public class SearchServiceHelper { | ||
350 | long now = DateUtil.getTimeSecondByDate(new Date()); | 343 | long now = DateUtil.getTimeSecondByDate(new Date()); |
351 | int begin = Integer.parseInt(paramMap.get(SearchRequestParams.PARAM_SEARCH_STOCKNUM)); | 344 | int begin = Integer.parseInt(paramMap.get(SearchRequestParams.PARAM_SEARCH_STOCKNUM)); |
352 | if (begin == 0) { | 345 | if (begin == 0) { |
353 | - boolFilter.must(QueryBuilders.termQuery("storageNum", begin)); | 346 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.storageNum, begin)); |
354 | } else { | 347 | } else { |
355 | if (StringUtils.isNotBlank(paramMap.get("showSoldOut")) && paramMap.get("showSoldOut").equals("1")) { | 348 | if (StringUtils.isNotBlank(paramMap.get("showSoldOut")) && paramMap.get("showSoldOut").equals("1")) { |
356 | - boolFilter.should(QueryBuilders.rangeQuery("storageNum").gte(begin)).should( | ||
357 | - QueryBuilders.boolQuery().must(QueryBuilders.termQuery("storageNum", 0)).must(QueryBuilders.rangeQuery("storageUpdateTime").gte(now))); | 349 | + boolFilter.should(QueryBuilders.rangeQuery(ProductIndexEsField.storageNum).gte(begin)).should( |
350 | + QueryBuilders.boolQuery().must(QueryBuilders.termQuery(ProductIndexEsField.storageNum, 0)) | ||
351 | + .must(QueryBuilders.rangeQuery(ProductIndexEsField.storageUpdateTime).gte(now))); | ||
358 | } else { | 352 | } else { |
359 | - boolFilter.must(QueryBuilders.rangeQuery("storageNum").gte(begin)); | 353 | + boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.storageNum).gte(begin)); |
360 | } | 354 | } |
361 | } | 355 | } |
362 | } | 356 | } |
363 | // 是否限量 | 357 | // 是否限量 |
364 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISLIMITED) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISLIMITED))) { | 358 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISLIMITED) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISLIMITED))) { |
365 | - boolFilter.must(QueryBuilders.termQuery("islimited", paramMap.get(SearchRequestParams.PARAM_SEARCH_ISLIMITED))); | 359 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.islimited, paramMap.get(SearchRequestParams.PARAM_SEARCH_ISLIMITED))); |
366 | } | 360 | } |
367 | // 是否限购 | 361 | // 是否限购 |
368 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISLIMITEDBUY) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISLIMITEDBUY))) { | 362 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISLIMITEDBUY) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISLIMITEDBUY))) { |
369 | - boolFilter.must(QueryBuilders.termQuery("isLimitbuy", paramMap.get(SearchRequestParams.PARAM_SEARCH_ISLIMITEDBUY))); | 363 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isLimitbuy, paramMap.get(SearchRequestParams.PARAM_SEARCH_ISLIMITEDBUY))); |
370 | } | 364 | } |
371 | // 是否预售 | 365 | // 是否预售 |
372 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISADVANCE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISADVANCE))) { | 366 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISADVANCE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISADVANCE))) { |
373 | - boolFilter.must(QueryBuilders.termQuery("isAdvance", paramMap.get(SearchRequestParams.PARAM_SEARCH_ISADVANCE))); | 367 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isAdvance, paramMap.get(SearchRequestParams.PARAM_SEARCH_ISADVANCE))); |
374 | }// 是否定金预售 | 368 | }// 是否定金预售 |
375 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISDESPOSITADVANCE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISDESPOSITADVANCE))) { | 369 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISDESPOSITADVANCE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISDESPOSITADVANCE))) { |
376 | - boolFilter.must(QueryBuilders.termQuery("isDepositAdvance", paramMap.get(SearchRequestParams.PARAM_SEARCH_ISDESPOSITADVANCE))); | 370 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isDepositAdvance, paramMap.get(SearchRequestParams.PARAM_SEARCH_ISDESPOSITADVANCE))); |
377 | } | 371 | } |
378 | // 是否新品 | 372 | // 是否新品 |
379 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISNEW) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISNEW))) { | 373 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISNEW) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISNEW))) { |
380 | - boolFilter.must(QueryBuilders.termQuery("isnew", paramMap.get(SearchRequestParams.PARAM_SEARCH_ISNEW))); | 374 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isnew, paramMap.get(SearchRequestParams.PARAM_SEARCH_ISNEW))); |
381 | } | 375 | } |
382 | // 是否奥莱 | 376 | // 是否奥莱 |
383 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISOUTLETS) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISOUTLETS))) { | 377 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ISOUTLETS) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISOUTLETS))) { |
384 | - boolFilter.must(QueryBuilders.termQuery("isOutlets", paramMap.get(SearchRequestParams.PARAM_SEARCH_ISOUTLETS))); | 378 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isOutlets, paramMap.get(SearchRequestParams.PARAM_SEARCH_ISOUTLETS))); |
385 | } | 379 | } |
386 | // 状态是否上架 | 380 | // 状态是否上架 |
387 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STATUS) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STATUS))) { | 381 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STATUS) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STATUS))) { |
388 | - boolFilter.must(QueryBuilders.termQuery(SearchRequestParams.PARAM_SEARCH_STATUS, paramMap.get(SearchRequestParams.PARAM_SEARCH_STATUS))); | 382 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.status, paramMap.get(SearchRequestParams.PARAM_SEARCH_STATUS))); |
389 | } | 383 | } |
390 | // APP类型 | 384 | // APP类型 |
391 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_APPTYPE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_APPTYPE)) | 385 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_APPTYPE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_APPTYPE)) |
392 | && !SearchRequestParams.PARAM_SEARCH_APPTYPE.equals(filterParamName)) { | 386 | && !SearchRequestParams.PARAM_SEARCH_APPTYPE.equals(filterParamName)) { |
393 | int[] appTypes = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_APPTYPE), ","); | 387 | int[] appTypes = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_APPTYPE), ","); |
394 | - boolFilter.must(QueryBuilders.termsQuery("appType", appTypes)); | 388 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.appType, appTypes)); |
395 | } | 389 | } |
396 | // 风格 | 390 | // 风格 |
397 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STYLE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STYLE)) | 391 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STYLE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STYLE)) |
398 | && !SearchRequestParams.PARAM_SEARCH_STYLE.equals(filterParamName)) { | 392 | && !SearchRequestParams.PARAM_SEARCH_STYLE.equals(filterParamName)) { |
399 | int[] styleids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_STYLE), ","); | 393 | int[] styleids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_STYLE), ","); |
400 | - boolFilter.must(QueryBuilders.termsQuery("styleIds", styleids)); | 394 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.styleIds, styleids)); |
401 | } | 395 | } |
402 | // 销售平台 (网站、APP、现场) | 396 | // 销售平台 (网站、APP、现场) |
403 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SELLCHANNELS) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SELLCHANNELS))) { | 397 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SELLCHANNELS) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SELLCHANNELS))) { |
404 | - boolFilter.must(QueryBuilders.termQuery("sellChannels", paramMap.get(SearchRequestParams.PARAM_SEARCH_SELLCHANNELS))); | 398 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.sellChannels, paramMap.get(SearchRequestParams.PARAM_SEARCH_SELLCHANNELS))); |
405 | } | 399 | } |
406 | if (paramMap.containsKey("folder_id") && StringUtils.isNotBlank(paramMap.get("folder_id"))) { | 400 | if (paramMap.containsKey("folder_id") && StringUtils.isNotBlank(paramMap.get("folder_id"))) { |
407 | - boolFilter.must(QueryBuilders.termQuery("folderId", paramMap.get("folder_id"))); | 401 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.folderId, paramMap.get("folder_id"))); |
408 | } | 402 | } |
409 | if (paramMap.containsKey("series_id") && StringUtils.isNotBlank(paramMap.get("series_id"))) { | 403 | if (paramMap.containsKey("series_id") && StringUtils.isNotBlank(paramMap.get("series_id"))) { |
410 | - boolFilter.must(QueryBuilders.termQuery("seriesId", paramMap.get("series_id"))); | 404 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.seriesId, paramMap.get("series_id"))); |
411 | } | 405 | } |
412 | // 促销折扣 | 406 | // 促销折扣 |
413 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_PDINT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_PDINT))) { | 407 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_PDINT) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_PDINT))) { |
@@ -417,7 +411,7 @@ public class SearchServiceHelper { | @@ -417,7 +411,7 @@ public class SearchServiceHelper { | ||
417 | } | 411 | } |
418 | double begin = Double.parseDouble(discounts[0]); | 412 | double begin = Double.parseDouble(discounts[0]); |
419 | double end = Double.parseDouble(discounts[1]); | 413 | double end = Double.parseDouble(discounts[1]); |
420 | - boolFilter.must(QueryBuilders.rangeQuery("promotionDiscountInt").gte(begin).lte(end)); | 414 | + boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.promotionDiscountInt).gte(begin).lte(end)); |
421 | } | 415 | } |
422 | // 首次上架时间间隔 | 416 | // 首次上架时间间隔 |
423 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_FIRST_SHELVE_TIME) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_FIRST_SHELVE_TIME)) | 417 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_FIRST_SHELVE_TIME) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_FIRST_SHELVE_TIME)) |
@@ -428,7 +422,7 @@ public class SearchServiceHelper { | @@ -428,7 +422,7 @@ public class SearchServiceHelper { | ||
428 | } | 422 | } |
429 | double begin = Double.parseDouble(times[0]); | 423 | double begin = Double.parseDouble(times[0]); |
430 | double end = Double.parseDouble(times[1]); | 424 | double end = Double.parseDouble(times[1]); |
431 | - boolFilter.must(QueryBuilders.rangeQuery("firstShelveTime").from(begin).to(end)); | 425 | + boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.firstShelveTime).from(begin).to(end)); |
432 | } | 426 | } |
433 | // 上架日期间隔 | 427 | // 上架日期间隔 |
434 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SHELVETIME) && !SearchRequestParams.PARAM_SEARCH_SHELVETIME.equals(filterParamName)) { | 428 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SHELVETIME) && !SearchRequestParams.PARAM_SEARCH_SHELVETIME.equals(filterParamName)) { |
@@ -438,7 +432,7 @@ public class SearchServiceHelper { | @@ -438,7 +432,7 @@ public class SearchServiceHelper { | ||
438 | } | 432 | } |
439 | double begin = Double.parseDouble(times[0]); | 433 | double begin = Double.parseDouble(times[0]); |
440 | double end = Double.parseDouble(times[1]); | 434 | double end = Double.parseDouble(times[1]); |
441 | - boolFilter.must(QueryBuilders.rangeQuery("shelveTime").from(begin).to(end)); | 435 | + boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.shelveTime).from(begin).to(end)); |
442 | } | 436 | } |
443 | // 上架日期 | 437 | // 上架日期 |
444 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_DAY) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_DAY))) { | 438 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_DAY) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_DAY))) { |
@@ -446,49 +440,50 @@ public class SearchServiceHelper { | @@ -446,49 +440,50 @@ public class SearchServiceHelper { | ||
446 | if (!DateUtil.isDate(recentDay)) { | 440 | if (!DateUtil.isDate(recentDay)) { |
447 | throw new IllegalArgumentException("wrong date format"); | 441 | throw new IllegalArgumentException("wrong date format"); |
448 | } | 442 | } |
449 | - boolFilter.must(QueryBuilders.termQuery("shelveDay", recentDay)); | 443 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.shelveDay, recentDay)); |
450 | } | 444 | } |
451 | // 增加活动模板相关的过滤条件 | 445 | // 增加活动模板相关的过滤条件 |
452 | BoolQueryBuilder activitiesTermsBuilder = searchCommonHelper.getActivitiesTermsBuilder(paramMap); | 446 | BoolQueryBuilder activitiesTermsBuilder = searchCommonHelper.getActivitiesTermsBuilder(paramMap); |
453 | if (activitiesTermsBuilder != null) { | 447 | if (activitiesTermsBuilder != null) { |
454 | - boolFilter.must(QueryBuilders.nestedQuery("activities", activitiesTermsBuilder)); | 448 | + boolFilter.must(QueryBuilders.nestedQuery(ProductIndexEsField.activities, activitiesTermsBuilder)); |
455 | } | 449 | } |
456 | // 断码(breakingRate>=50 || basePinRatio>=3.5) | 450 | // 断码(breakingRate>=50 || basePinRatio>=3.5) |
457 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_BREAKING) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_BREAKING))) { | 451 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_BREAKING) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_BREAKING))) { |
458 | String breaking = paramMap.get(SearchRequestParams.PARAM_SEARCH_BREAKING); | 452 | String breaking = paramMap.get(SearchRequestParams.PARAM_SEARCH_BREAKING); |
459 | if ("1".equals(breaking)) { | 453 | if ("1".equals(breaking)) { |
460 | - boolFilter.must(QueryBuilders.boolQuery().should(QueryBuilders.rangeQuery("breakingRate").from(50)).should(QueryBuilders.rangeQuery("basePinRatio").from(3.5))); | 454 | + boolFilter.must(QueryBuilders.boolQuery().should(QueryBuilders.rangeQuery(ProductIndexEsField.breakingRate).from(50)) |
455 | + .should(QueryBuilders.rangeQuery(ProductIndexEsField.basePinRatio).from(3.5))); | ||
461 | } | 456 | } |
462 | } | 457 | } |
463 | // SKN | 458 | // SKN |
464 | if (paramMap.containsKey(SearchRequestParams.PARAM_SYNC_SKN) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SYNC_SKN))) { | 459 | if (paramMap.containsKey(SearchRequestParams.PARAM_SYNC_SKN) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SYNC_SKN))) { |
465 | String sknString = paramMap.get(SearchRequestParams.PARAM_SYNC_SKN); | 460 | String sknString = paramMap.get(SearchRequestParams.PARAM_SYNC_SKN); |
466 | - boolFilter.must(QueryBuilders.termsQuery("productSkn", sknString.split(","))); | 461 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, sknString.split(","))); |
467 | } | 462 | } |
468 | // 年龄层 | 463 | // 年龄层 |
469 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_AGELEVEL) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_AGELEVEL)) | 464 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_AGELEVEL) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_AGELEVEL)) |
470 | && !SearchRequestParams.PARAM_SEARCH_AGELEVEL.equals(filterParamName)) { | 465 | && !SearchRequestParams.PARAM_SEARCH_AGELEVEL.equals(filterParamName)) { |
471 | int[] ageLevels = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_AGELEVEL), ","); | 466 | int[] ageLevels = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_AGELEVEL), ","); |
472 | - boolFilter.must(QueryBuilders.termsQuery("ageLevel", ageLevels)); | 467 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.ageLevel, ageLevels)); |
473 | } | 468 | } |
474 | // 判断是否需要包含全球购[全球购的开关] | 469 | // 判断是否需要包含全球购[全球购的开关] |
475 | if (!searchCommonHelper.containGlobal(paramMap)) { | 470 | if (!searchCommonHelper.containGlobal(paramMap)) { |
476 | - boolFilter.mustNot(QueryBuilders.termsQuery("isGlobal", "Y")); | 471 | + boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isGlobal, "Y")); |
477 | } | 472 | } |
478 | // 判断是否需要是筛选全球购[全球购的筛选项] | 473 | // 判断是否需要是筛选全球购[全球购的筛选项] |
479 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_IS_GLOBAL) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_IS_GLOBAL))) { | 474 | if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_IS_GLOBAL) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_IS_GLOBAL))) { |
480 | - boolFilter.must(QueryBuilders.termsQuery("isGlobal", paramMap.get(SearchRequestParams.PARAM_SEARCH_IS_GLOBAL))); | 475 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.isGlobal, paramMap.get(SearchRequestParams.PARAM_SEARCH_IS_GLOBAL))); |
481 | } | 476 | } |
482 | // 如果contain_seckill!=Y,则过滤掉秒杀商品 | 477 | // 如果contain_seckill!=Y,则过滤掉秒杀商品 |
483 | if (!paramMap.containsKey("contain_seckill") || !"Y".equals(paramMap.get("contain_seckill"))) { | 478 | if (!paramMap.containsKey("contain_seckill") || !"Y".equals(paramMap.get("contain_seckill"))) { |
484 | - boolFilter.mustNot(QueryBuilders.termsQuery("isSeckill", "Y")); | 479 | + boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isSeckill, "Y")); |
485 | } | 480 | } |
486 | // 用户VIP级别过滤 | 481 | // 用户VIP级别过滤 |
487 | String userVipLevel = (paramMap.get(SearchRequestParams.USER_VIP_LEVEL)); | 482 | String userVipLevel = (paramMap.get(SearchRequestParams.USER_VIP_LEVEL)); |
488 | if (StringUtils.isNotBlank(userVipLevel)) { | 483 | if (StringUtils.isNotBlank(userVipLevel)) { |
489 | List<String> userVipLevels = this.getUserVipLevels(userVipLevel); | 484 | List<String> userVipLevels = this.getUserVipLevels(userVipLevel); |
490 | if (userVipLevels != null) { | 485 | if (userVipLevels != null) { |
491 | - boolFilter.must(QueryBuilders.termsQuery("vipLevels", userVipLevels)); | 486 | + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.vipLevels, userVipLevels)); |
492 | } | 487 | } |
493 | } | 488 | } |
494 | // 通用的过滤请求 | 489 | // 通用的过滤请求 |
-
Please register or login to post a comment