|
|
package com.yoho.search.service.scene.common;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
|
|
import org.elasticsearch.search.aggregations.Aggregation;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.search.base.utils.ISearchConstants;
|
...
|
...
|
@@ -13,21 +29,6 @@ import com.yoho.search.service.aggregations.impls.AggregationFactoryService; |
|
|
import com.yoho.search.service.base.SearchCommonService;
|
|
|
import com.yoho.search.service.helper.SearchParamHelper;
|
|
|
import com.yoho.search.service.service.IAggRecommendService;
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
|
|
import org.elasticsearch.search.aggregations.Aggregation;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
@Service
|
|
|
public class SceneSelectionsService extends AbstractCacheAbleService {
|
...
|
...
|
@@ -43,7 +44,6 @@ public class SceneSelectionsService extends AbstractCacheAbleService { |
|
|
@Autowired
|
|
|
private IAggRecommendService aggRecommendService;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public SearchCache getSearchCache() {
|
|
|
return searchCacheFactory.getSelectionsForAppCache();
|
...
|
...
|
@@ -121,20 +121,46 @@ public class SceneSelectionsService extends AbstractCacheAbleService { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 店铺、新频到着的筛选项列表
|
|
|
* 最新降价的筛选项
|
|
|
*
|
|
|
* @param paramMap
|
|
|
* @return
|
|
|
*/
|
|
|
@SuppressWarnings("unused")
|
|
|
private List<IAggregation> getRNAggregations(Map<String, String> paramMap) {
|
|
|
public List<IAggregation> getReducePriceAggregations(Map<String, String> paramMap) {
|
|
|
List<IAggregation> aggregations = new ArrayList<>();
|
|
|
// 1)性别
|
|
|
aggregations.add(aggregationFactoryService.getGenderNewAggregation());
|
|
|
// 2)品类
|
|
|
// 2)品牌
|
|
|
aggregations.add(aggregationFactoryService.getBrandAggregation(paramMap));
|
|
|
// 3)品类
|
|
|
aggregations.add(aggregationFactoryService.getSortGroupAggregation(paramMap));
|
|
|
// 3)品牌
|
|
|
// 4)颜色
|
|
|
aggregations.add(aggregationFactoryService.getColorAggregation(paramMap));
|
|
|
// 5)尺码
|
|
|
aggregations.add(aggregationFactoryService.getSizeAggregation());
|
|
|
// 6)价格
|
|
|
aggregations.add(aggregationFactoryService.getPriceAggregation());
|
|
|
// 7)折扣
|
|
|
aggregations.add(aggregationFactoryService.getDiscountAggregation());
|
|
|
// 8)风格
|
|
|
aggregations.add(aggregationFactoryService.getStyleAggregation(paramMap));
|
|
|
return aggregations;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 老的店铺的筛选项
|
|
|
*
|
|
|
* @param paramMap
|
|
|
* @return
|
|
|
*/
|
|
|
public List<IAggregation> getShopOldAggregations(Map<String, String> paramMap) {
|
|
|
List<IAggregation> aggregations = new ArrayList<>();
|
|
|
// 1)性别
|
|
|
aggregations.add(aggregationFactoryService.getGenderNewAggregation());
|
|
|
// 2)品牌
|
|
|
aggregations.add(aggregationFactoryService.getBrandAggregation(paramMap));
|
|
|
// 3)品类
|
|
|
aggregations.add(aggregationFactoryService.getSortGroupAggregation(paramMap));
|
|
|
// 4)颜色
|
|
|
aggregations.add(aggregationFactoryService.getColorAggregation(paramMap));
|
|
|
// 5)尺码
|
...
|
...
|
@@ -143,6 +169,8 @@ public class SceneSelectionsService extends AbstractCacheAbleService { |
|
|
aggregations.add(aggregationFactoryService.getPriceAggregation());
|
|
|
// 7)折扣
|
|
|
aggregations.add(aggregationFactoryService.getDiscountAggregation());
|
|
|
// 8)风格
|
|
|
aggregations.add(aggregationFactoryService.getStyleAggregation(paramMap));
|
|
|
return aggregations;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -208,13 +236,13 @@ public class SceneSelectionsService extends AbstractCacheAbleService { |
|
|
return new JSONObject();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
private JSONArray getRecommendBrands(Map<String, String> paramMap, BoolQueryBuilder mustFilter) {
|
|
|
Map<String, String> newParamMap = new HashMap<String, String>(paramMap);
|
|
|
SearchApiResult searchApiResult = aggRecommendService.aggRecommendBrand(newParamMap, mustFilter);
|
|
|
return (JSONArray) searchApiResult.getData();
|
|
|
}
|
|
|
|
|
|
|
|
|
public SearchApiResult aggregations(Map<String, String> paramMap) throws Exception {
|
|
|
List<IAggregation> commonAggregations = this.getCommonAggregations(paramMap);
|
|
|
return this.aggregations(paramMap, commonAggregations, null);
|
...
|
...
|
|