Authored by Gino Zhang

suggest索引增加status service需要进行过滤

... ... @@ -57,6 +57,8 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl
private static final List<String> DEFAULT_SUGGEST_TIPS = Arrays.asList("潮流", "时尚", "休闲");
private static final int VALID_STATUS = 1;
@Autowired
private SearchCommonService searchCommonService;
@Autowired
... ... @@ -186,9 +188,12 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl
searchParam.setPage(1);
searchParam.setSize(size);
// count数量要>=1
String countEsField = getCountField(paramMap);
searchParam.setFiter(QueryBuilders.rangeQuery(countEsField).gte(2));
// count数量要>=2
final String countEsField = getCountField(paramMap);
BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
boolFilter.must(QueryBuilders.termQuery("status", VALID_STATUS));
boolFilter.must(QueryBuilders.rangeQuery(countEsField).gte(2));
searchParam.setFiter(boolFilter);
// 3)设置排序字段
List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>();
... ... @@ -307,6 +312,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl
searchParam.setSize(SMART_SUGGESTION_TERM_COUNT);
BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
boolFilter.must(QueryBuilders.termQuery("status", VALID_STATUS));
boolFilter.must(QueryBuilders.rangeQuery(countField).gte(SMART_SUGGESTION_COUNT_LIMIT));
boolFilter.mustNot(QueryBuilders.termQuery("standardKeyword", CharUtils.standardized(queryWord)));
searchParam.setFiter(boolFilter);
... ... @@ -385,7 +391,10 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl
searchParam.setSize(SMART_SUGGESTION_TERM_COUNT);
// 4.5) 过滤关联的商品数量小于20的关键词
searchParam.setFiter(QueryBuilders.rangeQuery(countFiled).gte(SMART_SUGGESTION_COUNT_LIMIT));
BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
boolFilter.must(QueryBuilders.termQuery("status", VALID_STATUS));
boolFilter.must(QueryBuilders.rangeQuery(countFiled).gte(SMART_SUGGESTION_COUNT_LIMIT));
searchParam.setFiter(boolFilter);
// 5) 先从缓存中获取
final String indexName = ISearchConstants.INDEX_NAME_SUGGEST;
... ...