...
|
...
|
@@ -6,6 +6,7 @@ import java.util.Map; |
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
|
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
|
|
import org.elasticsearch.search.aggregations.Aggregation;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
...
|
...
|
@@ -69,6 +70,14 @@ public class SplitSelectionsService extends BaseService { |
|
|
aggregationSearchCache = searchCacheFactory.getSelectionsForAppCache();
|
|
|
}
|
|
|
|
|
|
private List<AbstractAggregationBuilder> getAggregationBuilders(List<IAggregation> aggregations) {
|
|
|
List<AbstractAggregationBuilder> builders = new ArrayList<>();
|
|
|
for (IAggregation aggregation : aggregations) {
|
|
|
builders.add(aggregation.getBuilder());
|
|
|
}
|
|
|
return builders;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @聚合选项:
|
|
|
* @1、全球购
|
...
|
...
|
@@ -83,12 +92,17 @@ public class SplitSelectionsService extends BaseService { |
|
|
* @10、尺码
|
|
|
* @11、风格
|
|
|
*/
|
|
|
|
|
|
public JSONObject getCommonFilters(Map<String, String> paramMap) {
|
|
|
List<IAggregation> aggregations = this.getCommonAggregations(paramMap);
|
|
|
return this.getCommonFilters(paramMap, aggregations);
|
|
|
}
|
|
|
|
|
|
public JSONObject getCommonFilters(Map<String, String> paramMap, List<IAggregation> aggregations) {
|
|
|
try {
|
|
|
// 1)构造搜索参数
|
|
|
SearchParam searchParam = searchParamHelper.buildDefault(paramMap);
|
|
|
// 2)构造聚合报文
|
|
|
List<IAggregation> aggregations = this.getCommonFilterAggregations(paramMap);
|
|
|
searchParam.setAggregationBuilders(this.getAggregationBuilders(aggregations));
|
|
|
// 3)构造其他参数
|
|
|
final String productIndexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
|
...
|
...
|
@@ -122,7 +136,7 @@ public class SplitSelectionsService extends BaseService { |
|
|
}
|
|
|
}
|
|
|
|
|
|
private List<IAggregation> getCommonFilterAggregations(Map<String, String> paramMap) {
|
|
|
public List<IAggregation> getCommonAggregations(Map<String, String> paramMap) {
|
|
|
List<IAggregation> aggregations = new ArrayList<>();
|
|
|
// 1)促销
|
|
|
aggregations.add(aggregationFactoryService.getPromotionAggregation(1000));
|
...
|
...
|
@@ -149,9 +163,32 @@ public class SplitSelectionsService extends BaseService { |
|
|
return aggregations;
|
|
|
}
|
|
|
|
|
|
public List<IAggregation> getCouponAggregations(Map<String, String> paramMap) {
|
|
|
List<IAggregation> aggregations = new ArrayList<>();
|
|
|
// 1)性别
|
|
|
aggregations.add(aggregationFactoryService.getGenderNewAggregation());
|
|
|
// 2)品牌
|
|
|
aggregations.add(aggregationFactoryService.getBrandAggregation(paramMap));
|
|
|
// 3)人群
|
|
|
aggregations.add(aggregationFactoryService.getAgeLevelAggregation());
|
|
|
// 4)品类
|
|
|
aggregations.add(aggregationFactoryService.getSortGroupAggregation(paramMap));
|
|
|
// 5)颜色
|
|
|
aggregations.add(aggregationFactoryService.getColorAggregation(paramMap));
|
|
|
// 6)尺码
|
|
|
aggregations.add(aggregationFactoryService.getSizeAggregation());
|
|
|
// 7)价格
|
|
|
aggregations.add(aggregationFactoryService.getPriceAggregation());
|
|
|
// 8)折扣
|
|
|
aggregations.add(aggregationFactoryService.getDiscountAggregation());
|
|
|
// 9)风格
|
|
|
aggregations.add(aggregationFactoryService.getStyleAggregation(paramMap));
|
|
|
return aggregations;
|
|
|
}
|
|
|
|
|
|
public JSONArray getRecommendBrands(Map<String, String> paramMap) {
|
|
|
SearchApiResult searchApiResult = aggRecommendService.aggRecommendBrand(paramMap);
|
|
|
return (JSONArray)searchApiResult.getData();
|
|
|
return (JSONArray) searchApiResult.getData();
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|