|
@@ -10,6 +10,8 @@ import com.yoho.search.core.es.model.SearchParam; |
|
@@ -10,6 +10,8 @@ import com.yoho.search.core.es.model.SearchParam; |
10
|
import com.yoho.search.core.es.model.SearchResult;
|
10
|
import com.yoho.search.core.es.model.SearchResult;
|
11
|
import com.yoho.search.models.SearchApiResult;
|
11
|
import com.yoho.search.models.SearchApiResult;
|
12
|
import com.yoho.search.service.helper.ProductListHelper;
|
12
|
import com.yoho.search.service.helper.ProductListHelper;
|
|
|
13
|
+import com.yoho.search.service.helper.SearchParamHelper;
|
|
|
14
|
+import com.yoho.search.service.index.ProductIndexBaseService;
|
13
|
import com.yoho.search.service.recall.beans.strategy.NotRecallTypeEnum;
|
15
|
import com.yoho.search.service.recall.beans.strategy.NotRecallTypeEnum;
|
14
|
import org.apache.commons.lang.StringUtils;
|
16
|
import org.apache.commons.lang.StringUtils;
|
15
|
import org.slf4j.Logger;
|
17
|
import org.slf4j.Logger;
|
|
@@ -23,6 +25,8 @@ import java.util.List; |
|
@@ -23,6 +25,8 @@ import java.util.List; |
23
|
import java.util.Map;
|
25
|
import java.util.Map;
|
24
|
import java.util.stream.Collectors;
|
26
|
import java.util.stream.Collectors;
|
25
|
|
27
|
|
|
|
28
|
+import static java.util.stream.Collectors.joining;
|
|
|
29
|
+
|
26
|
/**
|
30
|
/**
|
27
|
* @author wangnan
|
31
|
* @author wangnan
|
28
|
* @version 2018/10/15
|
32
|
* @version 2018/10/15
|
|
@@ -36,6 +40,10 @@ public class ProductListBySknService { |
|
@@ -36,6 +40,10 @@ public class ProductListBySknService { |
36
|
private SearchCommonService searchCommonService;
|
40
|
private SearchCommonService searchCommonService;
|
37
|
@Autowired
|
41
|
@Autowired
|
38
|
private ProductListHelper productListHelper;
|
42
|
private ProductListHelper productListHelper;
|
|
|
43
|
+ @Autowired
|
|
|
44
|
+ private SearchParamHelper searchParamHelper;
|
|
|
45
|
+ @Autowired
|
|
|
46
|
+ private ProductIndexBaseService productIndexBaseService;
|
39
|
|
47
|
|
40
|
@SearchCacheAble(cacheInMinute = 10, cacheName = "PRODUCT_LIST_BY_SKN")
|
48
|
@SearchCacheAble(cacheInMinute = 10, cacheName = "PRODUCT_LIST_BY_SKN")
|
41
|
public SearchApiResult productListBySkn(Map<String, String> paramMap) {
|
49
|
public SearchApiResult productListBySkn(Map<String, String> paramMap) {
|
|
@@ -48,7 +56,14 @@ public class ProductListBySknService { |
|
@@ -48,7 +56,14 @@ public class ProductListBySknService { |
48
|
// 1)构造搜索参数
|
56
|
// 1)构造搜索参数
|
49
|
List<String> sknList = Arrays.asList(paramMap.get(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN).split(","));
|
57
|
List<String> sknList = Arrays.asList(paramMap.get(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN).split(","));
|
50
|
sknList = sknList.size() > 100 ? sknList.subList(0, 100) : sknList;
|
58
|
sknList = sknList.size() > 100 ? sknList.subList(0, 100) : sknList;
|
51
|
- SearchParam searchParam = productListHelper.buildProductListBySknSearchParam(paramMap, sknList.size());
|
59
|
+ String productSknParam = sknList.stream().collect(joining(","));
|
|
|
60
|
+ paramMap.put(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN,productSknParam);
|
|
|
61
|
+ SearchParam searchParam = searchParamHelper.buildWithPersional(paramMap, false);
|
|
|
62
|
+ searchParam.setAggregationBuilders(null);
|
|
|
63
|
+ searchParam.setSize(100);
|
|
|
64
|
+ searchParam.setOffset(0);
|
|
|
65
|
+ List<String> includeFields = productIndexBaseService.getProductIndexIncludeFields();
|
|
|
66
|
+ searchParam.setIncludeFields(includeFields);
|
52
|
|
67
|
|
53
|
// 2)查询ES
|
68
|
// 2)查询ES
|
54
|
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
|
69
|
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
|