suggest索引增加status service需要进行过滤
Showing
1 changed file
with
13 additions
and
4 deletions
@@ -57,6 +57,8 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | @@ -57,6 +57,8 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | ||
57 | 57 | ||
58 | private static final List<String> DEFAULT_SUGGEST_TIPS = Arrays.asList("潮流", "时尚", "休闲"); | 58 | private static final List<String> DEFAULT_SUGGEST_TIPS = Arrays.asList("潮流", "时尚", "休闲"); |
59 | 59 | ||
60 | + private static final int VALID_STATUS = 1; | ||
61 | + | ||
60 | @Autowired | 62 | @Autowired |
61 | private SearchCommonService searchCommonService; | 63 | private SearchCommonService searchCommonService; |
62 | @Autowired | 64 | @Autowired |
@@ -186,9 +188,12 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | @@ -186,9 +188,12 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | ||
186 | searchParam.setPage(1); | 188 | searchParam.setPage(1); |
187 | searchParam.setSize(size); | 189 | searchParam.setSize(size); |
188 | 190 | ||
189 | - // count数量要>=1 | ||
190 | - String countEsField = getCountField(paramMap); | ||
191 | - searchParam.setFiter(QueryBuilders.rangeQuery(countEsField).gte(2)); | 191 | + // count数量要>=2 |
192 | + final String countEsField = getCountField(paramMap); | ||
193 | + BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); | ||
194 | + boolFilter.must(QueryBuilders.termQuery("status", VALID_STATUS)); | ||
195 | + boolFilter.must(QueryBuilders.rangeQuery(countEsField).gte(2)); | ||
196 | + searchParam.setFiter(boolFilter); | ||
192 | 197 | ||
193 | // 3)设置排序字段 | 198 | // 3)设置排序字段 |
194 | List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>(); | 199 | List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>(); |
@@ -307,6 +312,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | @@ -307,6 +312,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | ||
307 | searchParam.setSize(SMART_SUGGESTION_TERM_COUNT); | 312 | searchParam.setSize(SMART_SUGGESTION_TERM_COUNT); |
308 | 313 | ||
309 | BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); | 314 | BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); |
315 | + boolFilter.must(QueryBuilders.termQuery("status", VALID_STATUS)); | ||
310 | boolFilter.must(QueryBuilders.rangeQuery(countField).gte(SMART_SUGGESTION_COUNT_LIMIT)); | 316 | boolFilter.must(QueryBuilders.rangeQuery(countField).gte(SMART_SUGGESTION_COUNT_LIMIT)); |
311 | boolFilter.mustNot(QueryBuilders.termQuery("standardKeyword", CharUtils.standardized(queryWord))); | 317 | boolFilter.mustNot(QueryBuilders.termQuery("standardKeyword", CharUtils.standardized(queryWord))); |
312 | searchParam.setFiter(boolFilter); | 318 | searchParam.setFiter(boolFilter); |
@@ -385,7 +391,10 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | @@ -385,7 +391,10 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl | ||
385 | searchParam.setSize(SMART_SUGGESTION_TERM_COUNT); | 391 | searchParam.setSize(SMART_SUGGESTION_TERM_COUNT); |
386 | 392 | ||
387 | // 4.5) 过滤关联的商品数量小于20的关键词 | 393 | // 4.5) 过滤关联的商品数量小于20的关键词 |
388 | - searchParam.setFiter(QueryBuilders.rangeQuery(countFiled).gte(SMART_SUGGESTION_COUNT_LIMIT)); | 394 | + BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); |
395 | + boolFilter.must(QueryBuilders.termQuery("status", VALID_STATUS)); | ||
396 | + boolFilter.must(QueryBuilders.rangeQuery(countFiled).gte(SMART_SUGGESTION_COUNT_LIMIT)); | ||
397 | + searchParam.setFiter(boolFilter); | ||
389 | 398 | ||
390 | // 5) 先从缓存中获取 | 399 | // 5) 先从缓存中获取 |
391 | final String indexName = ISearchConstants.INDEX_NAME_SUGGEST; | 400 | final String indexName = ISearchConstants.INDEX_NAME_SUGGEST; |
-
Please register or login to post a comment