|
@@ -10,6 +10,7 @@ import com.yoho.search.core.es.model.SearchResult; |
|
@@ -10,6 +10,7 @@ import com.yoho.search.core.es.model.SearchResult; |
10
|
import com.yoho.search.dal.model.Brand;
|
10
|
import com.yoho.search.dal.model.Brand;
|
11
|
import com.yoho.search.dal.model.ProductSort;
|
11
|
import com.yoho.search.dal.model.ProductSort;
|
12
|
import org.apache.commons.collections.CollectionUtils;
|
12
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
13
|
+import org.apache.commons.lang.StringUtils;
|
13
|
import org.elasticsearch.index.query.QueryBuilders;
|
14
|
import org.elasticsearch.index.query.QueryBuilders;
|
14
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
15
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
15
|
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
16
|
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
|
@@ -62,8 +63,10 @@ public class BrandWithSortNameSuggestionDiscoverer extends AbstractSuggestionDis |
|
@@ -62,8 +63,10 @@ public class BrandWithSortNameSuggestionDiscoverer extends AbstractSuggestionDis |
62
|
.subAggregation(AggregationBuilders.terms("smallSortAgg").field("smallSortId").size(10)));
|
63
|
.subAggregation(AggregationBuilders.terms("smallSortAgg").field("smallSortId").size(10)));
|
63
|
SearchResult searchResult = yohoIndexService.search(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
|
64
|
SearchResult searchResult = yohoIndexService.search(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
|
64
|
if (searchResult != null && searchResult.getAggMaps() != null && searchResult.getAggMaps().get("brandAgg") != null) {
|
65
|
if (searchResult != null && searchResult.getAggMaps() != null && searchResult.getAggMaps().get("brandAgg") != null) {
|
65
|
- Map<Integer, String> brandNameMap = brandList.stream().collect(Collectors.toMap(Brand::getId, Brand::getBrandName));
|
|
|
66
|
- Map<Integer, String> sortNameMap = productSortList.stream().collect(Collectors.toMap(ProductSort::getId, ProductSort::getSortName));
|
66
|
+ Map<Integer, String> brandNameMap = brandList.stream().filter(brand -> StringUtils.isNotEmpty(brand.getBrandName()))
|
|
|
67
|
+ .collect(Collectors.toMap(Brand::getId, Brand::getBrandName));
|
|
|
68
|
+ Map<Integer, String> sortNameMap = productSortList.stream().filter(sort -> StringUtils.isNotEmpty(sort.getSortName()))
|
|
|
69
|
+ .collect(Collectors.toMap(ProductSort::getId, ProductSort::getSortName));
|
67
|
|
70
|
|
68
|
MultiBucketsAggregation aggregation = (MultiBucketsAggregation) searchResult.getAggMaps().get("brandAgg");
|
71
|
MultiBucketsAggregation aggregation = (MultiBucketsAggregation) searchResult.getAggMaps().get("brandAgg");
|
69
|
Iterator<? extends MultiBucketsAggregation.Bucket> bucketIterator = aggregation.getBuckets().iterator();
|
72
|
Iterator<? extends MultiBucketsAggregation.Bucket> bucketIterator = aggregation.getBuckets().iterator();
|