|
|
package com.yoho.search.service.scene.general;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.search.base.utils.ISearchConstants;
|
|
|
import com.yoho.search.cache.beans.AbstractCacheAbleService;
|
|
|
import com.yoho.search.cache.CacheTimeConstants;
|
|
|
import com.yoho.search.cache.beans.AbstractCacheComponent;
|
|
|
import com.yoho.search.cache.log.SearchCacheMatchLogger;
|
|
|
import com.yoho.search.cache.model.SearchCache;
|
|
|
import com.yoho.search.common.SearchCommonService;
|
|
|
import com.yoho.search.common.SearchRequestParams;
|
|
|
import com.yoho.search.core.es.agg.IAggregation;
|
|
|
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.AggregationFactory;
|
|
|
import com.yoho.search.common.SearchCommonService;
|
|
|
import com.yoho.search.common.SearchRequestParams;
|
|
|
import com.yoho.search.service.helper.SearchParamHelper;
|
|
|
import com.yoho.search.service.helper.SearchQueryHelper;
|
|
|
import com.yoho.search.service.index.BrandIndexBaseService;
|
|
|
import com.yoho.search.service.index.ColorIndexBaseService;
|
|
|
import com.yoho.search.service.index.SizeIndexBaseService;
|
|
|
import com.yoho.search.service.index.StyleIndexBaseService;
|
|
|
import com.yoho.search.service.helper.SearchAfterCacheHelper;
|
|
|
import com.yoho.search.service.helper.SearchParamHelper;
|
|
|
import com.yoho.search.service.helper.SearchQueryHelper;
|
|
|
import com.yoho.search.service.recall.models.common.ParamQueryFilter;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
|
|
|
import com.yoho.search.models.SearchApiResult;
|
|
|
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
|
|
import org.elasticsearch.search.aggregations.Aggregation;
|
|
|
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
...
|
...
|
@@ -35,381 +31,384 @@ import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
@Service
|
|
|
public class SelectionsForPcService extends AbstractCacheAbleService {
|
|
|
public class SelectionsForPcService extends AbstractCacheComponent<JSONObject> {
|
|
|
|
|
|
@Autowired
|
|
|
private SearchParamHelper searchParamHelper;
|
|
|
@Autowired
|
|
|
private SearchQueryHelper searchQueryHelper;
|
|
|
@Autowired
|
|
|
private AggregationFactory aggregationFactory;
|
|
|
@Autowired
|
|
|
private SearchCommonService searchCommonService;
|
|
|
@Autowired
|
|
|
private BrandIndexBaseService brandIndexBaseService;
|
|
|
@Autowired
|
|
|
private ColorIndexBaseService colorIndexBaseService;
|
|
|
@Autowired
|
|
|
private StyleIndexBaseService styleIndexBaseService;
|
|
|
@Autowired
|
|
|
private SizeIndexBaseService sizeIndexBaseService;
|
|
|
|
|
|
@Autowired
|
|
|
private SearchParamHelper searchParamHelper;
|
|
|
@Autowired
|
|
|
private SearchQueryHelper searchQueryHelper;
|
|
|
@Autowired
|
|
|
private AggregationFactory aggregationFactory;
|
|
|
@Autowired
|
|
|
private SearchCommonService searchCommonService;
|
|
|
@Autowired
|
|
|
private SearchAfterCacheHelper searchAfterCacheService;
|
|
|
@Autowired
|
|
|
private BrandIndexBaseService brandIndexBaseService;
|
|
|
@Autowired
|
|
|
private ColorIndexBaseService colorIndexBaseService;
|
|
|
@Autowired
|
|
|
private StyleIndexBaseService styleIndexBaseService;
|
|
|
@Autowired
|
|
|
private SizeIndexBaseService sizeIndexBaseService;
|
|
|
private static Logger logger = LoggerFactory.getLogger(SelectionsForPcService.class);
|
|
|
|
|
|
@Override
|
|
|
public SearchCache getSearchCache() {
|
|
|
return searchCacheFactory.getSelectionsForPcCache();
|
|
|
}
|
|
|
public SearchApiResult getSelectionsForPc(Map<String, String> paramMap) {
|
|
|
try {
|
|
|
return this.getSelectionsForPc(paramMap, null);
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
return new SearchApiResult().setCode(500).setMessage("getSelectionsForPc Exception:" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(SelectionsForPcService.class);
|
|
|
public SearchApiResult getSelectionsForPc(Map<String, String> paramMap, BoolQueryBuilder mustFilter) throws Exception {
|
|
|
// 1)构造paramQueryFilter
|
|
|
ParamQueryFilter paramQueryFilter = searchParamHelper.buildParamQueryFilter(paramMap, mustFilter);
|
|
|
// 2)调父类查询
|
|
|
JSONObject result = super.queryWithCache(paramQueryFilter,paramMap);
|
|
|
// 3)生成结果
|
|
|
return new SearchApiResult().setData(result);
|
|
|
}
|
|
|
|
|
|
public SearchApiResult getSelectionsForPc(Map<String, String> paramMap) {
|
|
|
try {
|
|
|
return this.getSelectionsForPc(paramMap, null);
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
return new SearchApiResult().setCode(500).setMessage("getSelectionsForPc Exception:" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@Override
|
|
|
protected JSONObject doRealQuery(ParamQueryFilter paramQueryFilter, Map<String, String> paramMap) throws Exception {
|
|
|
//1、生成searchParam
|
|
|
SearchParam searchParam = searchParamHelper.buildSearchParam(paramQueryFilter);
|
|
|
searchParam.setOffset(0);
|
|
|
searchParam.setSize(0);
|
|
|
|
|
|
public SearchApiResult getSelectionsForPc(Map<String, String> paramMap, BoolQueryBuilder mustFilter) throws Exception {
|
|
|
// 1)构造SearchParam
|
|
|
SearchParam searchParam = searchParamHelper.buildWithMustFilter(paramMap, mustFilter);
|
|
|
searchParam.setOffset(3);// just for cache
|
|
|
searchParam.setSize(0);
|
|
|
//2)获取【提前聚合】的结果[必须用searchParam.clone(),因为外层的方法会传mustFilter]
|
|
|
Map<String, Object> preAggregationResult = this.preAggregationSearch(searchParam.clone(), paramMap);
|
|
|
|
|
|
SearchParam searchParamClone = searchParam.clone();// 用来缓存
|
|
|
String indexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
|
|
|
// 3)获取【非提前聚合的结果】
|
|
|
Map<String, Aggregation> aggMaps = new HashMap<String, Aggregation>();
|
|
|
searchParam.setAggregationBuilders(this.getOtherAggregations(paramMap));
|
|
|
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
|
|
|
if (searchResult != null && searchResult.getAggMaps() != null) {
|
|
|
aggMaps = searchResult.getAggMaps();
|
|
|
}
|
|
|
// 5)构造返回结果,并将结果缓存
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("filter", buildFilterResult(aggMaps, preAggregationResult, paramMap));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
// 2)从缓存里获取,取到则直接返回
|
|
|
JSONObject cacheObject = searchCacheService.getJSONObjectFromCache(this.searchCache, indexName, searchParamClone);
|
|
|
if (cacheObject != null) {
|
|
|
Object newCacheObject = searchAfterCacheService.dealFilterCacheObject(cacheObject);
|
|
|
SearchCacheMatchLogger.doSearchCacheMatchLog("/productindex/selectionsForPc.json", paramMap);
|
|
|
return new SearchApiResult().setData(newCacheObject);
|
|
|
}
|
|
|
@Override
|
|
|
protected int cacheTimeInMinute() {
|
|
|
return CacheTimeConstants.CACHE_15_MINUTE;
|
|
|
}
|
|
|
|
|
|
// 3)获取【提前聚合】的结果
|
|
|
Map<String, Object> preAggregationResult = this.preAggregationSearch(searchParam.clone(), paramMap);
|
|
|
@Override
|
|
|
protected String cacheSceneKey() {
|
|
|
return "SELECTIONS_FOR_PC";
|
|
|
}
|
|
|
|
|
|
// 4)获取【非提前聚合的结果】
|
|
|
Map<String, Aggregation> aggMaps = new HashMap<String, Aggregation>();
|
|
|
searchParam.setAggregationBuilders(this.getOtherAggregations(paramMap));
|
|
|
SearchResult searchResult = searchCommonService.doSearch(indexName, searchParam);
|
|
|
if (searchResult != null && searchResult.getAggMaps() != null) {
|
|
|
aggMaps = searchResult.getAggMaps();
|
|
|
}
|
|
|
// 5)构造返回结果,并将结果缓存
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("filter", buildFilterResult(aggMaps, preAggregationResult, paramMap));
|
|
|
searchCacheService.addJSONObjectToCache(this.searchCache, indexName, searchParamClone, result);
|
|
|
return new SearchApiResult().setData(result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 预聚合的属性,参数里有这些参数则优先聚合[因为filter的参数不同,聚合包含了一定的业务逻辑]
|
|
|
*
|
|
|
* @param searchParam
|
|
|
* @param paramMap
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private Map<String, Object> preAggregationSearch(SearchParam searchParam, Map<String, String> paramMap) throws Exception {
|
|
|
Map<String, Object> preAggregationResult = new HashMap<String, Object>();
|
|
|
// 1)年龄层
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_AGELEVEL) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_AGELEVEL))) {
|
|
|
IAggregation aggregation = aggregationFactory.getAgeLevelAggregation();
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(aggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_AGELEVEL));
|
|
|
preAggregationResult.put(aggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
// 2)性别
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_GENDER) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER))) {
|
|
|
IAggregation genderAggregation = aggregationFactory.getGenderAggregation(paramMap);
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(genderAggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_GENDER));
|
|
|
preAggregationResult.put(genderAggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
// 3)价格
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_PRICE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_PRICE))) {
|
|
|
IAggregation priceAggregation = aggregationFactory.getPriceAggregation();
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(priceAggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_PRICE));
|
|
|
preAggregationResult.put(priceAggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
// 4)颜色
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_COLOR) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_COLOR))) {
|
|
|
IAggregation colorAggregation = aggregationFactory.getColorAggregation(paramMap);
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(colorAggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_COLOR));
|
|
|
preAggregationResult.put(colorAggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
// 5)风格
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STYLE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STYLE))) {
|
|
|
IAggregation styleAggregation = aggregationFactory.getStyleAggregation(paramMap);
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(styleAggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_STYLE));
|
|
|
preAggregationResult.put(styleAggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
// 6)品牌
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_BRAND) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_BRAND))) {
|
|
|
IAggregation brandAggregation = aggregationFactory.getBrandAggregation(paramMap, 10);
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(brandAggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_BRAND));
|
|
|
preAggregationResult.put(brandAggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
return preAggregationResult;
|
|
|
}
|
|
|
/**
|
|
|
* 预聚合的属性,参数里有这些参数则优先聚合[因为filter的参数不同,聚合包含了一定的业务逻辑]
|
|
|
*
|
|
|
* @param searchParam
|
|
|
* @param paramMap
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private Map<String, Object> preAggregationSearch(SearchParam searchParam, Map<String, String> paramMap) throws Exception {
|
|
|
Map<String, Object> preAggregationResult = new HashMap<>();
|
|
|
// 1)年龄层
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_AGELEVEL) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_AGELEVEL))) {
|
|
|
IAggregation aggregation = aggregationFactory.getAgeLevelAggregation();
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(aggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_AGELEVEL));
|
|
|
preAggregationResult.put(aggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
// 2)性别
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_GENDER) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER))) {
|
|
|
IAggregation genderAggregation = aggregationFactory.getGenderAggregation(paramMap);
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(genderAggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_GENDER));
|
|
|
preAggregationResult.put(genderAggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
// 3)价格
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_PRICE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_PRICE))) {
|
|
|
IAggregation priceAggregation = aggregationFactory.getPriceAggregation();
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(priceAggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_PRICE));
|
|
|
preAggregationResult.put(priceAggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
// 4)颜色
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_COLOR) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_COLOR))) {
|
|
|
IAggregation colorAggregation = aggregationFactory.getColorAggregation(paramMap);
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(colorAggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_COLOR));
|
|
|
preAggregationResult.put(colorAggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
// 5)风格
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_STYLE) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_STYLE))) {
|
|
|
IAggregation styleAggregation = aggregationFactory.getStyleAggregation(paramMap);
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(styleAggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_STYLE));
|
|
|
preAggregationResult.put(styleAggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
// 6)品牌
|
|
|
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_BRAND) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_BRAND))) {
|
|
|
IAggregation brandAggregation = aggregationFactory.getBrandAggregation(paramMap, 10);
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(brandAggregation.getBuilder()));
|
|
|
searchParam.setFiter(searchQueryHelper.constructFilterBuilder(paramMap, SearchRequestParams.PARAM_SEARCH_BRAND));
|
|
|
preAggregationResult.put(brandAggregation.aggName(), doPreSearch(searchParam.clone(), paramMap));
|
|
|
}
|
|
|
return preAggregationResult;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 预聚合,并获取聚合结果[因为filter的参数不同,包含了一定的业务逻辑][针对这里做一下缓存]
|
|
|
*
|
|
|
* @param searchParam
|
|
|
* @param paramMap
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private Object doPreSearch(SearchParam searchParam, Map<String, String> paramMap) {
|
|
|
String indexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
|
|
|
/**
|
|
|
* 预聚合,并获取聚合结果[因为filter的参数不同,包含了一定的业务逻辑][针对这里做一下缓存]
|
|
|
*
|
|
|
* @param searchParam
|
|
|
* @param paramMap
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private Object doPreSearch(SearchParam searchParam, Map<String, String> paramMap) {
|
|
|
String indexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
|
|
|
|
|
|
SearchResult searchResult = searchCommonService.doSearch(indexName, searchParam);
|
|
|
Map<String, Aggregation> aggMaps = searchResult.getAggMaps();
|
|
|
if (aggMaps == null) {
|
|
|
return null;
|
|
|
}
|
|
|
// 1)获取年龄层的聚合结果
|
|
|
IAggregation ageLevelAggregation = aggregationFactory.getAgeLevelAggregation();
|
|
|
if (aggMaps.containsKey(ageLevelAggregation.aggName())) {
|
|
|
return ageLevelAggregation.getAggregationResponseMap(aggMaps);
|
|
|
}
|
|
|
// 2)获取性别层的聚合结果
|
|
|
IAggregation genderAggregation = aggregationFactory.getGenderAggregation(paramMap);
|
|
|
if (aggMaps.containsKey(genderAggregation.aggName())) {
|
|
|
Object genderResult = genderAggregation.getAggregationResponseMap(aggMaps);
|
|
|
return genderResult;
|
|
|
}
|
|
|
// 3)获取价格层的聚合结果
|
|
|
IAggregation priceAggregation = aggregationFactory.getPriceAggregation();
|
|
|
if (aggMaps.containsKey(priceAggregation.aggName())) {
|
|
|
return priceAggregation.getAggregationResponseMap(aggMaps);
|
|
|
}
|
|
|
// 4)获取颜色层的聚合结果
|
|
|
IAggregation collorAggregation = aggregationFactory.getColorAggregation(paramMap);
|
|
|
if (aggMaps.containsKey(collorAggregation.aggName())) {
|
|
|
return collorAggregation.getAggregationResponseMap(aggMaps);
|
|
|
}
|
|
|
// 5)获取风格层面的聚合结果
|
|
|
IAggregation styleAggregation = aggregationFactory.getStyleAggregation(paramMap);
|
|
|
if (aggMaps.containsKey(styleAggregation.aggName())) {
|
|
|
return styleAggregation.getAggregationResponseMap(aggMaps);
|
|
|
}
|
|
|
// 6)获取品牌层面的聚合结果
|
|
|
IAggregation brandaAggregation = aggregationFactory.getBrandAggregation(paramMap, 10);
|
|
|
if (aggMaps.containsKey(brandaAggregation.aggName())) {
|
|
|
return brandaAggregation.getAggregationResponseMap(aggMaps);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
SearchResult searchResult = searchCommonService.doSearch(indexName, searchParam);
|
|
|
Map<String, Aggregation> aggMaps = searchResult.getAggMaps();
|
|
|
if (aggMaps == null) {
|
|
|
return null;
|
|
|
}
|
|
|
// 1)获取年龄层的聚合结果
|
|
|
IAggregation ageLevelAggregation = aggregationFactory.getAgeLevelAggregation();
|
|
|
if (aggMaps.containsKey(ageLevelAggregation.aggName())) {
|
|
|
return ageLevelAggregation.getAggregationResponseMap(aggMaps);
|
|
|
}
|
|
|
// 2)获取性别层的聚合结果
|
|
|
IAggregation genderAggregation = aggregationFactory.getGenderAggregation(paramMap);
|
|
|
if (aggMaps.containsKey(genderAggregation.aggName())) {
|
|
|
Object genderResult = genderAggregation.getAggregationResponseMap(aggMaps);
|
|
|
return genderResult;
|
|
|
}
|
|
|
// 3)获取价格层的聚合结果
|
|
|
IAggregation priceAggregation = aggregationFactory.getPriceAggregation();
|
|
|
if (aggMaps.containsKey(priceAggregation.aggName())) {
|
|
|
return priceAggregation.getAggregationResponseMap(aggMaps);
|
|
|
}
|
|
|
// 4)获取颜色层的聚合结果
|
|
|
IAggregation collorAggregation = aggregationFactory.getColorAggregation(paramMap);
|
|
|
if (aggMaps.containsKey(collorAggregation.aggName())) {
|
|
|
return collorAggregation.getAggregationResponseMap(aggMaps);
|
|
|
}
|
|
|
// 5)获取风格层面的聚合结果
|
|
|
IAggregation styleAggregation = aggregationFactory.getStyleAggregation(paramMap);
|
|
|
if (aggMaps.containsKey(styleAggregation.aggName())) {
|
|
|
return styleAggregation.getAggregationResponseMap(aggMaps);
|
|
|
}
|
|
|
// 6)获取品牌层面的聚合结果
|
|
|
IAggregation brandaAggregation = aggregationFactory.getBrandAggregation(paramMap, 10);
|
|
|
if (aggMaps.containsKey(brandaAggregation.aggName())) {
|
|
|
return brandaAggregation.getAggregationResponseMap(aggMaps);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 构造所有的聚合参数
|
|
|
*
|
|
|
* @param paramMap
|
|
|
* @return
|
|
|
*/
|
|
|
private List<AbstractAggregationBuilder<?>> getOtherAggregations(Map<String, String> paramMap) {
|
|
|
List<AbstractAggregationBuilder<?>> list = new ArrayList<AbstractAggregationBuilder<?>>();
|
|
|
// 1)年龄层
|
|
|
if (!paramMap.containsKey("ageLevel") || StringUtils.isBlank(paramMap.get("ageLevel"))) {
|
|
|
list.add(aggregationFactory.getAgeLevelAggregation().getBuilder());
|
|
|
}
|
|
|
// 2)性别
|
|
|
if (!paramMap.containsKey("gender") || StringUtils.isBlank(paramMap.get("gender"))) {
|
|
|
list.add(aggregationFactory.getGenderAggregation(paramMap).getBuilder());
|
|
|
}
|
|
|
// 3)价格
|
|
|
if (!paramMap.containsKey("price") || StringUtils.isBlank(paramMap.get("price"))) {
|
|
|
list.add(aggregationFactory.getPriceAggregation().getBuilder());
|
|
|
}
|
|
|
// 4)颜色
|
|
|
if (!paramMap.containsKey("color") || StringUtils.isBlank(paramMap.get("color"))) {
|
|
|
list.add(aggregationFactory.getColorAggregation(paramMap).getBuilder());
|
|
|
}
|
|
|
// 5)风格
|
|
|
if (!paramMap.containsKey("style") || StringUtils.isBlank(paramMap.get("style"))) {
|
|
|
list.add(aggregationFactory.getStyleAggregation(paramMap).getBuilder());
|
|
|
}
|
|
|
// 5)品牌
|
|
|
if (!paramMap.containsKey("brand") || StringUtils.isBlank(paramMap.get("brand"))) {
|
|
|
list.add(aggregationFactory.getBrandAggregation(paramMap, 10).getBuilder());
|
|
|
}
|
|
|
// ************************************以下聚合只有不传相关参数的时候才会去聚合********************************/
|
|
|
// 7)【领型】【衣长】【袖长】【版型】【袖型】
|
|
|
list.add(aggregationFactory.getStandardAggregation(paramMap).getBuilder());
|
|
|
/**
|
|
|
* 构造所有的聚合参数
|
|
|
*
|
|
|
* @param paramMap
|
|
|
* @return
|
|
|
*/
|
|
|
private List<AbstractAggregationBuilder<?>> getOtherAggregations(Map<String, String> paramMap) {
|
|
|
List<AbstractAggregationBuilder<?>> list = new ArrayList<AbstractAggregationBuilder<?>>();
|
|
|
// 1)年龄层
|
|
|
if (!paramMap.containsKey("ageLevel") || StringUtils.isBlank(paramMap.get("ageLevel"))) {
|
|
|
list.add(aggregationFactory.getAgeLevelAggregation().getBuilder());
|
|
|
}
|
|
|
// 2)性别
|
|
|
if (!paramMap.containsKey("gender") || StringUtils.isBlank(paramMap.get("gender"))) {
|
|
|
list.add(aggregationFactory.getGenderAggregation(paramMap).getBuilder());
|
|
|
}
|
|
|
// 3)价格
|
|
|
if (!paramMap.containsKey("price") || StringUtils.isBlank(paramMap.get("price"))) {
|
|
|
list.add(aggregationFactory.getPriceAggregation().getBuilder());
|
|
|
}
|
|
|
// 4)颜色
|
|
|
if (!paramMap.containsKey("color") || StringUtils.isBlank(paramMap.get("color"))) {
|
|
|
list.add(aggregationFactory.getColorAggregation(paramMap).getBuilder());
|
|
|
}
|
|
|
// 5)风格
|
|
|
if (!paramMap.containsKey("style") || StringUtils.isBlank(paramMap.get("style"))) {
|
|
|
list.add(aggregationFactory.getStyleAggregation(paramMap).getBuilder());
|
|
|
}
|
|
|
// 5)品牌
|
|
|
if (!paramMap.containsKey("brand") || StringUtils.isBlank(paramMap.get("brand"))) {
|
|
|
list.add(aggregationFactory.getBrandAggregation(paramMap, 10).getBuilder());
|
|
|
}
|
|
|
// ************************************以下聚合只有不传相关参数的时候才会去聚合********************************/
|
|
|
// 7)【领型】【衣长】【袖长】【版型】【袖型】
|
|
|
list.add(aggregationFactory.getStandardAggregation(paramMap).getBuilder());
|
|
|
|
|
|
// 8)尺码
|
|
|
if (!paramMap.containsKey("size") || StringUtils.isBlank(paramMap.get("size"))) {
|
|
|
list.add(aggregationFactory.getSizeAggregation().getBuilder());
|
|
|
}
|
|
|
// 9)新品
|
|
|
if (!paramMap.containsKey("new") || StringUtils.isBlank(paramMap.get("new"))) {
|
|
|
list.add(aggregationFactory.getIsNewAggregation().getBuilder());
|
|
|
}
|
|
|
// 10)限量
|
|
|
if (!paramMap.containsKey("limited") || StringUtils.isBlank(paramMap.get("limited"))) {
|
|
|
list.add(aggregationFactory.getIsLimitedAggregation().getBuilder());
|
|
|
}
|
|
|
// 11)折扣
|
|
|
if (!paramMap.containsKey("specialoffer") || StringUtils.isBlank(paramMap.get("specialoffer"))) {
|
|
|
list.add(aggregationFactory.getIsSecialofferAggregation().getBuilder());
|
|
|
}
|
|
|
// 12)全球购
|
|
|
if (!paramMap.containsKey("is_global") || StringUtils.isBlank(paramMap.get("is_global"))) {
|
|
|
list.add(aggregationFactory.getIsGlobalAggregation().getBuilder());
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
// 8)尺码
|
|
|
if (!paramMap.containsKey("size") || StringUtils.isBlank(paramMap.get("size"))) {
|
|
|
list.add(aggregationFactory.getSizeAggregation().getBuilder());
|
|
|
}
|
|
|
// 9)新品
|
|
|
if (!paramMap.containsKey("new") || StringUtils.isBlank(paramMap.get("new"))) {
|
|
|
list.add(aggregationFactory.getIsNewAggregation().getBuilder());
|
|
|
}
|
|
|
// 10)限量
|
|
|
if (!paramMap.containsKey("limited") || StringUtils.isBlank(paramMap.get("limited"))) {
|
|
|
list.add(aggregationFactory.getIsLimitedAggregation().getBuilder());
|
|
|
}
|
|
|
// 11)折扣
|
|
|
if (!paramMap.containsKey("specialoffer") || StringUtils.isBlank(paramMap.get("specialoffer"))) {
|
|
|
list.add(aggregationFactory.getIsSecialofferAggregation().getBuilder());
|
|
|
}
|
|
|
// 12)全球购
|
|
|
if (!paramMap.containsKey("is_global") || StringUtils.isBlank(paramMap.get("is_global"))) {
|
|
|
list.add(aggregationFactory.getIsGlobalAggregation().getBuilder());
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
private Object getResponseByIAggregation(IAggregation aggregation, Map<String, Object> preAggregationResult, Map<String, Aggregation> aggMaps) {
|
|
|
boolean containedInPreResult = preAggregationResult.containsKey(aggregation.aggName());
|
|
|
Object ageLevelResponse = containedInPreResult ? preAggregationResult.get(aggregation.aggName()) : aggregation.getAggregationResponseMap(aggMaps);
|
|
|
return ageLevelResponse;
|
|
|
}
|
|
|
private Object getResponseByIAggregation(IAggregation aggregation, Map<String, Object> preAggregationResult, Map<String, Aggregation> aggMaps) {
|
|
|
boolean containedInPreResult = preAggregationResult.containsKey(aggregation.aggName());
|
|
|
Object ageLevelResponse = containedInPreResult ? preAggregationResult.get(aggregation.aggName()) : aggregation.getAggregationResponseMap(aggMaps);
|
|
|
return ageLevelResponse;
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
private Map<String, Object> buildFilterResult(Map<String, Aggregation> aggMaps, Map<String, Object> preAggregationResult, Map<String, String> paramMap) {
|
|
|
Map<String, Object> filter = new HashMap<String, Object>();
|
|
|
// 1)获取年龄的聚合结果
|
|
|
IAggregation ageLevelAggregation = aggregationFactory.getAgeLevelAggregation();
|
|
|
Object ageLevelResponse = this.getResponseByIAggregation(ageLevelAggregation, preAggregationResult, aggMaps);
|
|
|
if (ageLevelResponse != null) {
|
|
|
filter.put("ageLevel", ageLevelResponse);
|
|
|
}
|
|
|
// 2)获取性别的聚合结果
|
|
|
IAggregation genderAggregation = aggregationFactory.getGenderAggregation(paramMap);
|
|
|
Object genderResponse = this.getResponseByIAggregation(genderAggregation, preAggregationResult, aggMaps);
|
|
|
if (genderResponse != null) {
|
|
|
filter.put("gender", genderResponse);
|
|
|
}
|
|
|
// 3)获取价格层面的聚合结果
|
|
|
IAggregation priceAggregation = aggregationFactory.getPriceAggregation();
|
|
|
Object priceResponse = this.getResponseByIAggregation(priceAggregation, preAggregationResult, aggMaps);
|
|
|
if (priceResponse != null) {
|
|
|
filter.put("price", priceResponse);
|
|
|
} else {
|
|
|
filter.put("price", this.getDeaultPriceMap());
|
|
|
}
|
|
|
// 4)获取颜色层面的聚合结果
|
|
|
IAggregation colorAggregation = aggregationFactory.getColorAggregation(paramMap);
|
|
|
Object colorResponse = this.getResponseByIAggregation(colorAggregation, preAggregationResult, aggMaps);
|
|
|
if (colorResponse != null) {
|
|
|
filter.put("color", colorResponse);
|
|
|
} else {
|
|
|
filter.put("color", colorIndexBaseService.getColorListByIdStr(paramMap.get("color")));
|
|
|
}
|
|
|
// 5)获取风格层面的聚合结果
|
|
|
IAggregation styleAggregation = aggregationFactory.getStyleAggregation(paramMap);
|
|
|
Object styleResponse = this.getResponseByIAggregation(styleAggregation, preAggregationResult, aggMaps);
|
|
|
if (styleResponse != null) {
|
|
|
filter.put("style", styleResponse);
|
|
|
} else {
|
|
|
filter.put("style", styleIndexBaseService.getStyleListByIdStr(paramMap.get("style")));
|
|
|
}
|
|
|
// 6)获取品牌层面的聚合结果
|
|
|
IAggregation brandAggregation = aggregationFactory.getBrandAggregation(paramMap, 10);
|
|
|
Object brandResponse = this.getResponseByIAggregation(brandAggregation, preAggregationResult, aggMaps);
|
|
|
if (brandResponse != null) {
|
|
|
filter.put("brand", brandResponse);
|
|
|
} else {
|
|
|
filter.put("brand", brandIndexBaseService.getBrandListByIdStr(paramMap.get("brand")));
|
|
|
}
|
|
|
// 7) 如果参数里面有brand,则将此brand返回给PC
|
|
|
if (StringUtils.isNotBlank(paramMap.get("brand"))) {
|
|
|
filter.put("paramBrand", brandIndexBaseService.getBrandListByIdStr(paramMap.get("brand")));
|
|
|
} else {
|
|
|
filter.put("paramBrand", new JSONArray());
|
|
|
}
|
|
|
@SuppressWarnings("unchecked")
|
|
|
private Map<String, Object> buildFilterResult(Map<String, Aggregation> aggMaps, Map<String, Object> preAggregationResult, Map<String, String> paramMap) {
|
|
|
Map<String, Object> filter = new HashMap<String, Object>();
|
|
|
// 1)获取年龄的聚合结果
|
|
|
IAggregation ageLevelAggregation = aggregationFactory.getAgeLevelAggregation();
|
|
|
Object ageLevelResponse = this.getResponseByIAggregation(ageLevelAggregation, preAggregationResult, aggMaps);
|
|
|
if (ageLevelResponse != null) {
|
|
|
filter.put("ageLevel", ageLevelResponse);
|
|
|
}
|
|
|
// 2)获取性别的聚合结果
|
|
|
IAggregation genderAggregation = aggregationFactory.getGenderAggregation(paramMap);
|
|
|
Object genderResponse = this.getResponseByIAggregation(genderAggregation, preAggregationResult, aggMaps);
|
|
|
if (genderResponse != null) {
|
|
|
filter.put("gender", genderResponse);
|
|
|
}
|
|
|
// 3)获取价格层面的聚合结果
|
|
|
IAggregation priceAggregation = aggregationFactory.getPriceAggregation();
|
|
|
Object priceResponse = this.getResponseByIAggregation(priceAggregation, preAggregationResult, aggMaps);
|
|
|
if (priceResponse != null) {
|
|
|
filter.put("price", priceResponse);
|
|
|
} else {
|
|
|
filter.put("price", this.getDeaultPriceMap());
|
|
|
}
|
|
|
// 4)获取颜色层面的聚合结果
|
|
|
IAggregation colorAggregation = aggregationFactory.getColorAggregation(paramMap);
|
|
|
Object colorResponse = this.getResponseByIAggregation(colorAggregation, preAggregationResult, aggMaps);
|
|
|
if (colorResponse != null) {
|
|
|
filter.put("color", colorResponse);
|
|
|
} else {
|
|
|
filter.put("color", colorIndexBaseService.getColorListByIdStr(paramMap.get("color")));
|
|
|
}
|
|
|
// 5)获取风格层面的聚合结果
|
|
|
IAggregation styleAggregation = aggregationFactory.getStyleAggregation(paramMap);
|
|
|
Object styleResponse = this.getResponseByIAggregation(styleAggregation, preAggregationResult, aggMaps);
|
|
|
if (styleResponse != null) {
|
|
|
filter.put("style", styleResponse);
|
|
|
} else {
|
|
|
filter.put("style", styleIndexBaseService.getStyleListByIdStr(paramMap.get("style")));
|
|
|
}
|
|
|
// 6)获取品牌层面的聚合结果
|
|
|
IAggregation brandAggregation = aggregationFactory.getBrandAggregation(paramMap, 10);
|
|
|
Object brandResponse = this.getResponseByIAggregation(brandAggregation, preAggregationResult, aggMaps);
|
|
|
if (brandResponse != null) {
|
|
|
filter.put("brand", brandResponse);
|
|
|
} else {
|
|
|
filter.put("brand", brandIndexBaseService.getBrandListByIdStr(paramMap.get("brand")));
|
|
|
}
|
|
|
// 7) 如果参数里面有brand,则将此brand返回给PC
|
|
|
if (StringUtils.isNotBlank(paramMap.get("brand"))) {
|
|
|
filter.put("paramBrand", brandIndexBaseService.getBrandListByIdStr(paramMap.get("brand")));
|
|
|
} else {
|
|
|
filter.put("paramBrand", new JSONArray());
|
|
|
}
|
|
|
|
|
|
// 8)获取尺码聚合结果[尺码不会提前聚合]
|
|
|
IAggregation sizeAggregation = aggregationFactory.getSizeAggregation();
|
|
|
Object sizeResponse = this.getResponseByIAggregation(sizeAggregation, preAggregationResult, aggMaps);
|
|
|
if (sizeResponse != null) {
|
|
|
filter.put("size", sizeResponse);
|
|
|
} else {
|
|
|
filter.put("size", sizeIndexBaseService.getSizeListByIdStr(paramMap.get("size")));
|
|
|
}
|
|
|
// 8)获取尺码聚合结果[尺码不会提前聚合]
|
|
|
IAggregation sizeAggregation = aggregationFactory.getSizeAggregation();
|
|
|
Object sizeResponse = this.getResponseByIAggregation(sizeAggregation, preAggregationResult, aggMaps);
|
|
|
if (sizeResponse != null) {
|
|
|
filter.put("size", sizeResponse);
|
|
|
} else {
|
|
|
filter.put("size", sizeIndexBaseService.getSizeListByIdStr(paramMap.get("size")));
|
|
|
}
|
|
|
|
|
|
// 9)获取规则的聚合结果[规格不会提前聚合]
|
|
|
IAggregation standardAggregation = aggregationFactory.getStandardAggregation(paramMap);
|
|
|
Object standardResponse = this.getResponseByIAggregation(standardAggregation, preAggregationResult, aggMaps);
|
|
|
if (standardResponse != null) {
|
|
|
Iterator<Entry<String, Object>> entryStandard = ((Map<String, Object>) standardResponse).entrySet().iterator();
|
|
|
while (entryStandard.hasNext()) {
|
|
|
Entry<String, Object> entry = entryStandard.next();
|
|
|
if (paramMap.containsKey(entry.getKey())) {
|
|
|
filter.put(entry.getKey(), entry.getValue());
|
|
|
} else {
|
|
|
filter.put(entry.getKey(), entry.getValue());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 返回最新、限量、折扣
|
|
|
this.setNLS(aggMaps, filter);
|
|
|
return filter;
|
|
|
}
|
|
|
// 9)获取规则的聚合结果[规格不会提前聚合]
|
|
|
IAggregation standardAggregation = aggregationFactory.getStandardAggregation(paramMap);
|
|
|
Object standardResponse = this.getResponseByIAggregation(standardAggregation, preAggregationResult, aggMaps);
|
|
|
if (standardResponse != null) {
|
|
|
Iterator<Entry<String, Object>> entryStandard = ((Map<String, Object>) standardResponse).entrySet().iterator();
|
|
|
while (entryStandard.hasNext()) {
|
|
|
Entry<String, Object> entry = entryStandard.next();
|
|
|
if (paramMap.containsKey(entry.getKey())) {
|
|
|
filter.put(entry.getKey(), entry.getValue());
|
|
|
} else {
|
|
|
filter.put(entry.getKey(), entry.getValue());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 返回最新、限量、折扣
|
|
|
this.setNLS(aggMaps, filter);
|
|
|
return filter;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取默认的价格区间
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, Object> getDeaultPriceMap() {
|
|
|
Map<String, Object> priceMap = new LinkedHashMap<String, Object>();
|
|
|
priceMap.put("0,300", "¥0-300");
|
|
|
priceMap.put("300,600", "¥300-600");
|
|
|
priceMap.put("600,1000", "¥600-1000");
|
|
|
priceMap.put("1000,2000", "¥1000-2000");
|
|
|
priceMap.put("2000,99999", "¥2000以上");
|
|
|
return priceMap;
|
|
|
}
|
|
|
/**
|
|
|
* 获取默认的价格区间
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, Object> getDeaultPriceMap() {
|
|
|
Map<String, Object> priceMap = new LinkedHashMap<String, Object>();
|
|
|
priceMap.put("0,300", "¥0-300");
|
|
|
priceMap.put("300,600", "¥300-600");
|
|
|
priceMap.put("600,1000", "¥600-1000");
|
|
|
priceMap.put("1000,2000", "¥1000-2000");
|
|
|
priceMap.put("2000,99999", "¥2000以上");
|
|
|
return priceMap;
|
|
|
}
|
|
|
|
|
|
// 返回最新、限量、折扣的聚合结果
|
|
|
public void setNLS(Map<String, Aggregation> aggMaps, Map<String, Object> result) {
|
|
|
if (aggMaps.containsKey("isnewAgg")) {
|
|
|
if (getNLSMap((MultiBucketsAggregation) aggMaps.get("isnewAgg"))) {
|
|
|
result.put("new", "Y");
|
|
|
}
|
|
|
}
|
|
|
if (aggMaps.containsKey("islimitedAgg")) {
|
|
|
if (getNLSMap((MultiBucketsAggregation) aggMaps.get("islimitedAgg"))) {
|
|
|
result.put("limited", "Y");
|
|
|
}
|
|
|
}
|
|
|
if (aggMaps.containsKey("specialofferAgg")) {
|
|
|
if (getNLSMap((MultiBucketsAggregation) aggMaps.get("specialofferAgg"))) {
|
|
|
result.put("specialoffer", "Y");
|
|
|
}
|
|
|
}
|
|
|
if (aggMaps.containsKey("isGlobalAgg")) {
|
|
|
if (getNLSMap((MultiBucketsAggregation) aggMaps.get("isGlobalAgg"))) {
|
|
|
result.put("is_global", "Y");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 返回最新、限量、折扣的聚合结果
|
|
|
public void setNLS(Map<String, Aggregation> aggMaps, Map<String, Object> result) {
|
|
|
if (aggMaps.containsKey("isnewAgg")) {
|
|
|
if (getNLSMap((MultiBucketsAggregation) aggMaps.get("isnewAgg"))) {
|
|
|
result.put("new", "Y");
|
|
|
}
|
|
|
}
|
|
|
if (aggMaps.containsKey("islimitedAgg")) {
|
|
|
if (getNLSMap((MultiBucketsAggregation) aggMaps.get("islimitedAgg"))) {
|
|
|
result.put("limited", "Y");
|
|
|
}
|
|
|
}
|
|
|
if (aggMaps.containsKey("specialofferAgg")) {
|
|
|
if (getNLSMap((MultiBucketsAggregation) aggMaps.get("specialofferAgg"))) {
|
|
|
result.put("specialoffer", "Y");
|
|
|
}
|
|
|
}
|
|
|
if (aggMaps.containsKey("isGlobalAgg")) {
|
|
|
if (getNLSMap((MultiBucketsAggregation) aggMaps.get("isGlobalAgg"))) {
|
|
|
result.put("is_global", "Y");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private boolean getNLSMap(MultiBucketsAggregation aggregation) {
|
|
|
Iterator<? extends Bucket> itAgg = aggregation.getBuckets().iterator();
|
|
|
while (itAgg.hasNext()) {
|
|
|
Bucket bucket = itAgg.next();
|
|
|
// String bool = bucket.getKexy();
|
|
|
String bool = bucket.getKeyAsString();
|
|
|
if ("Y".equals(bool)) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
private boolean getNLSMap(MultiBucketsAggregation aggregation) {
|
|
|
Iterator<? extends Bucket> itAgg = aggregation.getBuckets().iterator();
|
|
|
while (itAgg.hasNext()) {
|
|
|
Bucket bucket = itAgg.next();
|
|
|
String bool = bucket.getKeyAsString();
|
|
|
if ("Y".equals(bool)) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|