|
@@ -96,13 +96,11 @@ public class SearchService { |
|
@@ -96,13 +96,11 @@ public class SearchService { |
96
|
jsonMap.put("data", "");
|
96
|
jsonMap.put("data", "");
|
97
|
return jsonMap;
|
97
|
return jsonMap;
|
98
|
}
|
98
|
}
|
99
|
- if (searchResult.getAggMaps() != null) {
|
99
|
+ //获取聚合结果
|
|
|
100
|
+ Object discountAggResult = discountAggregation.getAggregationResponseMap(searchResult.getAggMaps());
|
|
|
101
|
+ if (discountAggResult != null) {
|
100
|
Map<String, Object> filter = new HashMap<String, Object>();
|
102
|
Map<String, Object> filter = new HashMap<String, Object>();
|
101
|
- Map<String, Aggregation> aggMaps = searchResult.getAggMaps();
|
|
|
102
|
- Object discountAggResult = discountAggregation.getAggregationResponseMap(aggMaps);
|
|
|
103
|
- if (discountAggResult != null) {
|
|
|
104
|
- filter.put("discount", discountAggResult);
|
|
|
105
|
- }
|
103
|
+ filter.put("discount", discountAggResult);
|
106
|
jsonMap.put("data", filter);
|
104
|
jsonMap.put("data", filter);
|
107
|
} else {
|
105
|
} else {
|
108
|
jsonMap.put("data", "");
|
106
|
jsonMap.put("data", "");
|
|
@@ -111,13 +109,6 @@ public class SearchService { |
|
@@ -111,13 +109,6 @@ public class SearchService { |
111
|
return jsonMap;
|
109
|
return jsonMap;
|
112
|
}
|
110
|
}
|
113
|
|
111
|
|
114
|
- public Map<String, Object> makeValueMap(String name, long count) {
|
|
|
115
|
- Map<String, Object> valueMap = new HashMap<String, Object>();
|
|
|
116
|
- valueMap.put("name", name);
|
|
|
117
|
- valueMap.put("count", count);
|
|
|
118
|
- return valueMap;
|
|
|
119
|
- }
|
|
|
120
|
-
|
|
|
121
|
/**
|
112
|
/**
|
122
|
* 制作过滤条件报文
|
113
|
* 制作过滤条件报文
|
123
|
* */
|
114
|
* */
|
|
@@ -133,37 +124,6 @@ public class SearchService { |
|
@@ -133,37 +124,6 @@ public class SearchService { |
133
|
return searchCommonService.doMultiGet(indexName, set, null);
|
124
|
return searchCommonService.doMultiGet(indexName, set, null);
|
134
|
}
|
125
|
}
|
135
|
|
126
|
|
136
|
- public List<Map<String, Object>> getFilterResponseMapForBrand(MultiBucketsAggregation aggregation, String indexName, String[] ids) throws Exception {
|
|
|
137
|
- Set<String> set = new LinkedHashSet<String>();
|
|
|
138
|
- Iterator<? extends Bucket> itSizeAgg = aggregation.getBuckets().iterator();
|
|
|
139
|
- while (itSizeAgg.hasNext()) {
|
|
|
140
|
- Bucket ltSize = itSizeAgg.next();
|
|
|
141
|
- for (String sizeId : ltSize.getKey().split(",")) {
|
|
|
142
|
- set.add(sizeId);
|
|
|
143
|
- }
|
|
|
144
|
- }
|
|
|
145
|
- for (String id : ids) {
|
|
|
146
|
- set.add(id);
|
|
|
147
|
- }
|
|
|
148
|
- return searchCommonService.doMultiGet(indexName, set, null);
|
|
|
149
|
- }
|
|
|
150
|
-
|
|
|
151
|
- /**
|
|
|
152
|
- * 获取按最近上架时间聚合的结果
|
|
|
153
|
- *
|
|
|
154
|
- * @param aggregation
|
|
|
155
|
- * @return
|
|
|
156
|
- */
|
|
|
157
|
- public Map<String, Object> getRecentShelveDayResponseMap(MultiBucketsAggregation aggregation) {
|
|
|
158
|
- Map<String, Object> map = new LinkedHashMap<String, Object>();
|
|
|
159
|
- Iterator<? extends Bucket> itAgg = aggregation.getBuckets().iterator();
|
|
|
160
|
- while (itAgg.hasNext()) {
|
|
|
161
|
- Bucket lt = itAgg.next();
|
|
|
162
|
- map.put(lt.getKey(), lt.getDocCount());
|
|
|
163
|
- }
|
|
|
164
|
- return map;
|
|
|
165
|
- }
|
|
|
166
|
-
|
|
|
167
|
/**
|
127
|
/**
|
168
|
* 获取按上架日期聚合的结果[日期列表]
|
128
|
* 获取按上架日期聚合的结果[日期列表]
|
169
|
*
|
129
|
*
|
|
@@ -181,9 +141,8 @@ public class SearchService { |
|
@@ -181,9 +141,8 @@ public class SearchService { |
181
|
searchParam.setFiter(searchServiceHelper.constructFilterBuilder(paramMap, null));
|
141
|
searchParam.setFiter(searchServiceHelper.constructFilterBuilder(paramMap, null));
|
182
|
|
142
|
|
183
|
// 构造聚合参数
|
143
|
// 构造聚合参数
|
184
|
- List<AbstractAggregationBuilder> list = new ArrayList<AbstractAggregationBuilder>();
|
|
|
185
|
- list.add(AggregationBuilders.terms("recentShelveDay").field("shelveDay").size(7).order(Terms.Order.term(false)));
|
|
|
186
|
- searchParam.setAggregationBuilders(list);
|
144
|
+ IAggregation recentShelveDayAggregation = aggregationFactoryService.getRecentShelveDayAggregation();
|
|
|
145
|
+ searchParam.setAggregationBuilders(Arrays.asList(recentShelveDayAggregation.getBuilder()));
|
187
|
searchParam.setSearchType(SearchType.COUNT);
|
146
|
searchParam.setSearchType(SearchType.COUNT);
|
188
|
|
147
|
|
189
|
// 进行检索
|
148
|
// 进行检索
|
|
@@ -199,12 +158,12 @@ public class SearchService { |
|
@@ -199,12 +158,12 @@ public class SearchService { |
199
|
jsonMap.put("data", "");
|
158
|
jsonMap.put("data", "");
|
200
|
return jsonMap;
|
159
|
return jsonMap;
|
201
|
}
|
160
|
}
|
202
|
- if (searchResult.getAggMaps() != null) {
|
161
|
+
|
|
|
162
|
+ // 获取聚合结果
|
|
|
163
|
+ Object recentShelveDayResponse = recentShelveDayAggregation.getAggregationResponseMap(searchResult.getAggMaps());
|
|
|
164
|
+ if (recentShelveDayResponse != null) {
|
203
|
Map<String, Object> filter = new HashMap<String, Object>();
|
165
|
Map<String, Object> filter = new HashMap<String, Object>();
|
204
|
- Map<String, Aggregation> aggMaps = searchResult.getAggMaps();
|
|
|
205
|
- if (aggMaps.containsKey("recentShelveDay")) {
|
|
|
206
|
- filter.put("recent", this.getRecentShelveDayResponseMap((MultiBucketsAggregation) aggMaps.get("recentShelveDay")));
|
|
|
207
|
- }
|
166
|
+ filter.put("recent", recentShelveDayResponse);
|
208
|
jsonMap.put("data", filter);
|
167
|
jsonMap.put("data", filter);
|
209
|
} else {
|
168
|
} else {
|
210
|
jsonMap.put("data", "");
|
169
|
jsonMap.put("data", "");
|
|
@@ -648,7 +607,7 @@ public class SearchService { |
|
@@ -648,7 +607,7 @@ public class SearchService { |
648
|
}
|
607
|
}
|
649
|
return brandAlifMap;
|
608
|
return brandAlifMap;
|
650
|
}
|
609
|
}
|
651
|
-
|
610
|
+
|
652
|
/**
|
611
|
/**
|
653
|
* 根据query关键字获取商品总数
|
612
|
* 根据query关键字获取商品总数
|
654
|
*
|
613
|
*
|