Authored by 胡古飞

fix

... ... @@ -12,12 +12,11 @@ import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.core.es.agg.AbstractAggregation;
import com.yoho.search.service.service.base.ColorIndexBaseService;
public class ColorAggregation extends AbstractAggregation {
private ColorIndexBaseService colorIndexBaseService;
private Map<String, String> paramMap;
... ...
package com.yoho.search.service.aggregations.impls;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
... ... @@ -32,14 +30,13 @@ public class IsGlobalAggregation extends AbstractAggregation {
return null;
}
Iterator<? extends Bucket> itAgg = aggregation.getBuckets().iterator();
List<String> isGlobals = new ArrayList<>();
while (itAgg.hasNext()) {
Bucket bucket = itAgg.next();
String bool = bucket.getKeyAsString();
if("Y".equals(bool) || "N".equals(bool)){
isGlobals.add(bool);
if ("Y".equals(bool)) {
return true;
}
}
return isGlobals;
return false;
}
}
... ...
package com.yoho.search.service.servicenew.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.core.es.agg.IAggregation;
... ... @@ -176,7 +177,7 @@ public class SelectionWithOutAdvanceImpl implements ISelectionsWithOutAdvanceSer
if (colorResponse != null) {
filter.put("color", colorResponse);
} else {
filter.put("color", colorIndexBaseService.getColorListByIds(Arrays.asList(paramMap.get("color").split(","))));
filter.put("color", new JSONArray());
}
// 5)获取风格层面的聚合结果
... ... @@ -203,7 +204,7 @@ public class SelectionWithOutAdvanceImpl implements ISelectionsWithOutAdvanceSer
if (sizeResponse != null) {
filter.put("size", sizeResponse);
} else {
filter.put("size", searchCommonService.doMultiGet(ISearchConstants.INDEX_NAME_SIZE, paramMap.get("size").split(","), null));
filter.put("size", new JSONArray());
}
// 8)获取规则的聚合结果[规格不会提前聚合]
... ... @@ -221,20 +222,14 @@ public class SelectionWithOutAdvanceImpl implements ISelectionsWithOutAdvanceSer
}
}
}
// 9) 返回最新、限量、折扣
this.setNLS(aggMaps, filter);
// 9) 返回最新、限量、折扣、全球購
this.setOthers(aggMaps, filter);
// 10) 返回全球购的筛选项
IAggregation isGlobalAgg = aggregationFactoryService.getIsGlobalAggregation();
Object globalResponse = isGlobalAgg.getAggregationResponseMap(aggMaps);
if (globalResponse != null) {
filter.put("global", globalResponse);
}
return filter;
}
// 返回最新、限量、折扣的聚合结果
public void setNLS(Map<String, Aggregation> aggMaps, Map<String, Object> result) {
public void setOthers(Map<String, Aggregation> aggMaps, Map<String, Object> result) {
if (aggMaps.containsKey("isnewAgg")) {
if (getNLSMap((MultiBucketsAggregation) aggMaps.get("isnewAgg"))) {
result.put("new", "Y");
... ... @@ -250,6 +245,11 @@ public class SelectionWithOutAdvanceImpl implements ISelectionsWithOutAdvanceSer
result.put("specialoffer", "Y");
}
}
if (aggMaps.containsKey("isGlobalAgg")) {
if (getNLSMap((MultiBucketsAggregation) aggMaps.get("specialofferAgg"))) {
result.put("is_global", "Y");
}
}
}
private boolean getNLSMap(MultiBucketsAggregation aggregation) {
... ...