...
|
...
|
@@ -8,8 +8,6 @@ import java.util.concurrent.CompletableFuture; |
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
|
|
import org.elasticsearch.search.aggregations.Aggregation;
|
...
|
...
|
@@ -21,7 +19,6 @@ import org.springframework.stereotype.Service; |
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.search.base.utils.ISearchConstants;
|
|
|
import com.yoho.search.common.cache.SearchCacheFactory;
|
|
|
import com.yoho.search.common.cache.SearchCacheMatchLogger;
|
|
|
import com.yoho.search.common.cache.model.SearchCache;
|
|
|
import com.yoho.search.core.es.agg.IAggregation;
|
...
|
...
|
@@ -29,54 +26,32 @@ import com.yoho.search.core.es.model.SearchParam; |
|
|
import com.yoho.search.core.es.model.SearchResult;
|
|
|
import com.yoho.search.models.SearchApiResult;
|
|
|
import com.yoho.search.service.aggregations.impls.AggregationFactoryService;
|
|
|
import com.yoho.search.service.base.SearchCacheService;
|
|
|
import com.yoho.search.service.base.SearchCommonService;
|
|
|
import com.yoho.search.service.base.SearchDynamicConfigService;
|
|
|
import com.yoho.search.service.base.index.ProductIndexBaseService;
|
|
|
import com.yoho.search.service.helper.SearchCommonHelper;
|
|
|
import com.yoho.search.service.helper.SearchKeyWordHelper;
|
|
|
import com.yoho.search.service.helper.SearchParamHelper;
|
|
|
import com.yoho.search.service.service.IAggRecommendService;
|
|
|
import com.yoho.search.service.service.ISearchRecommendService;
|
|
|
import com.yoho.search.service.service.impl.BaseService;
|
|
|
|
|
|
@Service
|
|
|
public class SceneSelectionsService extends BaseService {
|
|
|
public class SceneSelectionsService extends AbstractCacheAbleService {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(SceneSelectionsService.class);
|
|
|
|
|
|
@Autowired
|
|
|
private SearchCommonHelper searchCommonHelper;
|
|
|
@Autowired
|
|
|
private SearchParamHelper searchParamHelper;
|
|
|
@Autowired
|
|
|
private SearchCommonService searchCommonService;
|
|
|
@Autowired
|
|
|
private SearchKeyWordHelper searchKeyWordService;
|
|
|
@Autowired
|
|
|
private ISearchRecommendService searchRecommendService;
|
|
|
@Autowired
|
|
|
private SearchDynamicConfigService searchDynamicConfigService;
|
|
|
@Autowired
|
|
|
private ProductIndexBaseService productIndexBaseService;
|
|
|
@Autowired
|
|
|
private SearchCacheService searchCacheService;
|
|
|
@Autowired
|
|
|
private SearchCacheFactory searchCacheFactory;
|
|
|
@Autowired
|
|
|
private AggregationFactoryService aggregationFactoryService;
|
|
|
@Autowired
|
|
|
private IAggRecommendService aggRecommendService;
|
|
|
|
|
|
private SearchCache aggregationSearchCache;
|
|
|
|
|
|
@Override
|
|
|
public SearchCache getSearchCache() {
|
|
|
return searchCacheFactory.getSelectionsForAppCache();
|
|
|
}
|
|
|
|
|
|
private ExecutorService executorService = Executors.newFixedThreadPool(100);
|
|
|
|
|
|
@PostConstruct
|
|
|
void init() {
|
|
|
aggregationSearchCache = searchCacheFactory.getSelectionsForAppCache();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @新版筛选器的聚合选项:
|
|
|
* @1、全球购
|
...
|
...
|
@@ -202,7 +177,7 @@ public class SceneSelectionsService extends BaseService { |
|
|
searchParam.setSize(0);
|
|
|
|
|
|
// 先从缓存里取,取到则处理下缓存结果并直接返回
|
|
|
JSONObject cacheObject = searchCacheService.getJSONObjectFromCache(aggregationSearchCache, productIndexName, searchParam);
|
|
|
JSONObject cacheObject = searchCacheService.getJSONObjectFromCache(this.searchCache, productIndexName, searchParam);
|
|
|
if (cacheObject != null) {
|
|
|
SearchCacheMatchLogger.doSearchCacheMatchLog("/scene/aggregations.json", paramMap);
|
|
|
return cacheObject;
|
...
|
...
|
@@ -216,7 +191,7 @@ public class SceneSelectionsService extends BaseService { |
|
|
}
|
|
|
// 构造返回结果
|
|
|
JSONObject dataMap = this.genFilterResult(aggregations, aggMaps);
|
|
|
searchCacheService.addJSONObjectToCache(aggregationSearchCache, productIndexName, searchParam, dataMap);
|
|
|
searchCacheService.addJSONObjectToCache(this.searchCache, productIndexName, searchParam, dataMap);
|
|
|
return dataMap;
|
|
|
} catch (Exception e) {
|
|
|
logger.error("[func=getFiltersResults][params=" + paramMap + "]", e);
|
...
|
...
|
|