Authored by Gino Zhang

Merge branch 'test' of git.yoho.cn:yoho-search/yoho-search-service into test

... ... @@ -29,7 +29,7 @@ public class SizeAggregation extends AbstractAggregation {
@Override
public AbstractAggregationBuilder getBuilder() {
return AggregationBuilders.terms(aggName()).field("sizeIds").size(100);
return AggregationBuilders.terms(aggName()).field("sizeIds").size(300);
}
@Override
... ...
... ... @@ -2,12 +2,15 @@ package com.yoho.search.service.service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.get.MultiGetItemResponse;
... ... @@ -208,12 +211,25 @@ public class SearchCommonService implements ApplicationEventPublisherAware {
}
}
} else if (indexName.equals(ISearchConstants.INDEX_NAME_SIZE)) {
List<Map<String, Object>> sizeResults = new ArrayList<Map<String, Object>>();
for (MultiGetItemResponse item : response.getResponses()) {
if (item.getResponse().isExists()) {
tmpMap = item.getResponse().getSource();
list.add(getSizeMap(tmpMap));
sizeResults.add(item.getResponse().getSource());
}
}
//按orderby排序
Collections.sort(sizeResults,new Comparator<Map<String, Object>>(){
@Override
public int compare(Map<String, Object> size1, Map<String, Object> size2) {
int orderBy1 = MapUtils.getIntValue(size1, "orderBy");
int orderBy2 = MapUtils.getIntValue(size2, "orderBy");
return (orderBy1 - orderBy2) * (-1);
}
});
for (Map<String, Object> sizeResult : sizeResults) {
list.add(getSizeMap(sizeResult));
}
} else if (indexName.equals(ISearchConstants.INDEX_NAME_STYLE)) {
for (MultiGetItemResponse item : response.getResponses()) {
if (item.getResponse().isExists()) {
... ...