...
|
...
|
@@ -96,13 +96,11 @@ public class SearchService { |
|
|
jsonMap.put("data", "");
|
|
|
return jsonMap;
|
|
|
}
|
|
|
if (searchResult.getAggMaps() != null) {
|
|
|
//获取聚合结果
|
|
|
Object discountAggResult = discountAggregation.getAggregationResponseMap(searchResult.getAggMaps());
|
|
|
if (discountAggResult != null) {
|
|
|
Map<String, Object> filter = new HashMap<String, Object>();
|
|
|
Map<String, Aggregation> aggMaps = searchResult.getAggMaps();
|
|
|
Object discountAggResult = discountAggregation.getAggregationResponseMap(aggMaps);
|
|
|
if (discountAggResult != null) {
|
|
|
filter.put("discount", discountAggResult);
|
|
|
}
|
|
|
filter.put("discount", discountAggResult);
|
|
|
jsonMap.put("data", filter);
|
|
|
} else {
|
|
|
jsonMap.put("data", "");
|
...
|
...
|
@@ -111,13 +109,6 @@ public class SearchService { |
|
|
return jsonMap;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> makeValueMap(String name, long count) {
|
|
|
Map<String, Object> valueMap = new HashMap<String, Object>();
|
|
|
valueMap.put("name", name);
|
|
|
valueMap.put("count", count);
|
|
|
return valueMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 制作过滤条件报文
|
|
|
* */
|
...
|
...
|
@@ -133,37 +124,6 @@ public class SearchService { |
|
|
return searchCommonService.doMultiGet(indexName, set, null);
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getFilterResponseMapForBrand(MultiBucketsAggregation aggregation, String indexName, String[] ids) throws Exception {
|
|
|
Set<String> set = new LinkedHashSet<String>();
|
|
|
Iterator<? extends Bucket> itSizeAgg = aggregation.getBuckets().iterator();
|
|
|
while (itSizeAgg.hasNext()) {
|
|
|
Bucket ltSize = itSizeAgg.next();
|
|
|
for (String sizeId : ltSize.getKey().split(",")) {
|
|
|
set.add(sizeId);
|
|
|
}
|
|
|
}
|
|
|
for (String id : ids) {
|
|
|
set.add(id);
|
|
|
}
|
|
|
return searchCommonService.doMultiGet(indexName, set, null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取按最近上架时间聚合的结果
|
|
|
*
|
|
|
* @param aggregation
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, Object> getRecentShelveDayResponseMap(MultiBucketsAggregation aggregation) {
|
|
|
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
|
|
Iterator<? extends Bucket> itAgg = aggregation.getBuckets().iterator();
|
|
|
while (itAgg.hasNext()) {
|
|
|
Bucket lt = itAgg.next();
|
|
|
map.put(lt.getKey(), lt.getDocCount());
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取按上架日期聚合的结果[日期列表]
|
|
|
*
|
...
|
...
|
@@ -181,9 +141,8 @@ public class SearchService { |
|
|
searchParam.setFiter(searchServiceHelper.constructFilterBuilder(paramMap, null));
|
|
|
|
|
|
// 构造聚合参数
|
|
|
List<AbstractAggregationBuilder> list = new ArrayList<AbstractAggregationBuilder>();
|
|
|
list.add(AggregationBuilders.terms("recentShelveDay").field("shelveDay").size(7).order(Terms.Order.term(false)));
|
|
|
searchParam.setAggregationBuilders(list);
|
|
|
IAggregation recentShelveDayAggregation = aggregationFactoryService.getRecentShelveDayAggregation();
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(recentShelveDayAggregation.getBuilder()));
|
|
|
searchParam.setSearchType(SearchType.COUNT);
|
|
|
|
|
|
// 进行检索
|
...
|
...
|
@@ -199,12 +158,12 @@ public class SearchService { |
|
|
jsonMap.put("data", "");
|
|
|
return jsonMap;
|
|
|
}
|
|
|
if (searchResult.getAggMaps() != null) {
|
|
|
|
|
|
// 获取聚合结果
|
|
|
Object recentShelveDayResponse = recentShelveDayAggregation.getAggregationResponseMap(searchResult.getAggMaps());
|
|
|
if (recentShelveDayResponse != null) {
|
|
|
Map<String, Object> filter = new HashMap<String, Object>();
|
|
|
Map<String, Aggregation> aggMaps = searchResult.getAggMaps();
|
|
|
if (aggMaps.containsKey("recentShelveDay")) {
|
|
|
filter.put("recent", this.getRecentShelveDayResponseMap((MultiBucketsAggregation) aggMaps.get("recentShelveDay")));
|
|
|
}
|
|
|
filter.put("recent", recentShelveDayResponse);
|
|
|
jsonMap.put("data", filter);
|
|
|
} else {
|
|
|
jsonMap.put("data", "");
|
...
|
...
|
@@ -648,7 +607,7 @@ public class SearchService { |
|
|
}
|
|
|
return brandAlifMap;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据query关键字获取商品总数
|
|
|
*
|
...
|
...
|
|