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