Showing
3 changed files
with
18 additions
and
28 deletions
1 | -package com.yoho.search.service.servicenew.impl; | 1 | +package com.yoho.search.service.service.helper; |
2 | 2 | ||
3 | import java.util.ArrayList; | 3 | import java.util.ArrayList; |
4 | import java.util.Arrays; | 4 | import java.util.Arrays; |
@@ -20,38 +20,26 @@ import com.yoho.search.core.es.model.SearchParam; | @@ -20,38 +20,26 @@ import com.yoho.search.core.es.model.SearchParam; | ||
20 | import com.yoho.search.core.es.model.SearchResult; | 20 | import com.yoho.search.core.es.model.SearchResult; |
21 | import com.yoho.search.service.service.SearchCacheService; | 21 | import com.yoho.search.service.service.SearchCacheService; |
22 | import com.yoho.search.service.service.SearchCommonService; | 22 | import com.yoho.search.service.service.SearchCommonService; |
23 | -import com.yoho.search.service.service.helper.AggProductListHelper; | ||
24 | -import com.yoho.search.service.service.helper.FunctionScoreSearchHelper; | ||
25 | -import com.yoho.search.service.service.helper.SearchCommonHelper; | ||
26 | -import com.yoho.search.service.service.helper.SearchServiceHelper; | ||
27 | -import com.yoho.search.service.service.helper.SearchSortHelper; | ||
28 | import com.yoho.search.service.vo.SearchFieldBoost; | 23 | import com.yoho.search.service.vo.SearchFieldBoost; |
29 | 24 | ||
30 | @Component | 25 | @Component |
31 | -public class SearchLikeCommonService { | 26 | +public class SearchLikeHelper { |
32 | 27 | ||
33 | @Autowired | 28 | @Autowired |
34 | - private SearchCommonHelper searchCommonHelper; | ||
35 | - @Autowired | ||
36 | private SearchCommonService searchCommonService; | 29 | private SearchCommonService searchCommonService; |
37 | - @Autowired | ||
38 | private SearchServiceHelper searchServiceHelper; | 30 | private SearchServiceHelper searchServiceHelper; |
39 | @Autowired | 31 | @Autowired |
40 | - private SearchSortHelper searchSortHelper; | ||
41 | - @Autowired | ||
42 | private SearchCacheService searchCacheService; | 32 | private SearchCacheService searchCacheService; |
43 | @Autowired | 33 | @Autowired |
44 | private FunctionScoreSearchHelper functionScoreSearchHelper; | 34 | private FunctionScoreSearchHelper functionScoreSearchHelper; |
45 | - @Autowired | ||
46 | - private AggProductListHelper aggProductListHelper; | ||
47 | 35 | ||
48 | public List<SearchFieldBoost> searchFieldBoosts = new ArrayList<SearchFieldBoost>(); | 36 | public List<SearchFieldBoost> searchFieldBoosts = new ArrayList<SearchFieldBoost>(); |
49 | 37 | ||
50 | private int sortMaxBoost = 1000; | 38 | private int sortMaxBoost = 1000; |
51 | - private int brandMaxBoost = 700; | 39 | + private int brandMaxBoost = 400; |
52 | private int productNameMaxBoost = 600; | 40 | private int productNameMaxBoost = 600; |
53 | - private int standardOnlyNamesBoost = 500; | ||
54 | - private int otherBoost = 150; | 41 | + private int standardOnlyNamesBoost = 700; |
42 | + private int otherBoost = 200; | ||
55 | 43 | ||
56 | private void addSearchFieldBoost(List<String> searchFields, float maxBoost) { | 44 | private void addSearchFieldBoost(List<String> searchFields, float maxBoost) { |
57 | float boost = maxBoost; | 45 | float boost = maxBoost; |
@@ -25,6 +25,7 @@ import com.yoho.search.service.service.SearchCommonService; | @@ -25,6 +25,7 @@ import com.yoho.search.service.service.SearchCommonService; | ||
25 | import com.yoho.search.service.service.helper.AggProductListHelper; | 25 | import com.yoho.search.service.service.helper.AggProductListHelper; |
26 | import com.yoho.search.service.service.helper.FunctionScoreSearchHelper; | 26 | import com.yoho.search.service.service.helper.FunctionScoreSearchHelper; |
27 | import com.yoho.search.service.service.helper.SearchCommonHelper; | 27 | import com.yoho.search.service.service.helper.SearchCommonHelper; |
28 | +import com.yoho.search.service.service.helper.SearchLikeHelper; | ||
28 | import com.yoho.search.service.service.helper.SearchServiceHelper; | 29 | import com.yoho.search.service.service.helper.SearchServiceHelper; |
29 | import com.yoho.search.service.service.helper.SearchSortHelper; | 30 | import com.yoho.search.service.service.helper.SearchSortHelper; |
30 | import com.yoho.search.service.servicenew.ISearchLikeInShopService; | 31 | import com.yoho.search.service.servicenew.ISearchLikeInShopService; |
@@ -49,7 +50,7 @@ public class SearchLikeInShopServiceImpl implements ISearchLikeInShopService { | @@ -49,7 +50,7 @@ public class SearchLikeInShopServiceImpl implements ISearchLikeInShopService { | ||
49 | @Autowired | 50 | @Autowired |
50 | private AggProductListHelper aggProductListHelper; | 51 | private AggProductListHelper aggProductListHelper; |
51 | @Autowired | 52 | @Autowired |
52 | - private SearchLikeCommonService searchLikeCommonService; | 53 | + private SearchLikeHelper searchLikeHelper; |
53 | 54 | ||
54 | public boolean isLegalInteger(Integer id) { | 55 | public boolean isLegalInteger(Integer id) { |
55 | if (id != null && id > 0) { | 56 | if (id != null && id > 0) { |
@@ -66,7 +67,7 @@ public class SearchLikeInShopServiceImpl implements ISearchLikeInShopService { | @@ -66,7 +67,7 @@ public class SearchLikeInShopServiceImpl implements ISearchLikeInShopService { | ||
66 | return new SearchApiResult().setCode(400).setMessage("请输入SKN"); | 67 | return new SearchApiResult().setCode(400).setMessage("请输入SKN"); |
67 | } | 68 | } |
68 | // 2、获取当前查询的SKN的基本信息 | 69 | // 2、获取当前查询的SKN的基本信息 |
69 | - JSONObject productInfoInEs = searchLikeCommonService.getProductInfoInEs(productSkn); | 70 | + JSONObject productInfoInEs = searchLikeHelper.getProductInfoInEs(productSkn); |
70 | if (productInfoInEs == null) { | 71 | if (productInfoInEs == null) { |
71 | return new SearchApiResult().setCode(400).setMessage("SKN不存在"); | 72 | return new SearchApiResult().setCode(400).setMessage("SKN不存在"); |
72 | } | 73 | } |
@@ -90,11 +91,11 @@ public class SearchLikeInShopServiceImpl implements ISearchLikeInShopService { | @@ -90,11 +91,11 @@ public class SearchLikeInShopServiceImpl implements ISearchLikeInShopService { | ||
90 | String brandName = productInfoInEs.getString("brandName"); | 91 | String brandName = productInfoInEs.getString("brandName"); |
91 | String productFeatureFactor = productInfoInEs.getString("productFeatureFactor"); | 92 | String productFeatureFactor = productInfoInEs.getString("productFeatureFactor"); |
92 | String query = brandName + "," + productName + "," + standardOnlyNames + "," + style; | 93 | String query = brandName + "," + productName + "," + standardOnlyNames + "," + style; |
93 | - QueryBuilder queryBuilder = searchLikeCommonService.genSearchLikeQueryBuilder(query, "40%", productFeatureFactor); | 94 | + QueryBuilder queryBuilder = searchLikeHelper.genSearchLikeQueryBuilder(query, "40%", productFeatureFactor); |
94 | searchParam.setQuery(queryBuilder); | 95 | searchParam.setQuery(queryBuilder); |
95 | - | 96 | + |
96 | // 5、设置filter | 97 | // 5、设置filter |
97 | - BoolQueryBuilder boolFilter = searchLikeCommonService.genDefaultQueryBuilder(Arrays.asList(productSkn)); | 98 | + BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultQueryBuilder(Arrays.asList(productSkn)); |
98 | Integer brandId = productInfoInEs.getInteger("brandId"); | 99 | Integer brandId = productInfoInEs.getInteger("brandId"); |
99 | Integer shopId = productInfoInEs.getInteger("shopId"); | 100 | Integer shopId = productInfoInEs.getInteger("shopId"); |
100 | if (isLegalInteger(shopId)) { | 101 | if (isLegalInteger(shopId)) { |
@@ -131,7 +132,7 @@ public class SearchLikeInShopServiceImpl implements ISearchLikeInShopService { | @@ -131,7 +132,7 @@ public class SearchLikeInShopServiceImpl implements ISearchLikeInShopService { | ||
131 | jsonObject.put("page_total", 1); | 132 | jsonObject.put("page_total", 1); |
132 | jsonObject.put("page_size", pageSize); | 133 | jsonObject.put("page_size", pageSize); |
133 | jsonObject.put("total", productList.size()); | 134 | jsonObject.put("total", productList.size()); |
134 | - jsonObject.put("product_info", searchLikeCommonService.genProductInfoResult(productInfoInEs)); | 135 | + jsonObject.put("product_info", searchLikeHelper.genProductInfoResult(productInfoInEs)); |
135 | jsonObject.put("product_list", productList); | 136 | jsonObject.put("product_list", productList); |
136 | searchCacheService.addJSONObjectToCache(cacheEnum, productIndexName, searchParam, jsonObject); | 137 | searchCacheService.addJSONObjectToCache(cacheEnum, productIndexName, searchParam, jsonObject); |
137 | return new SearchApiResult().setData(jsonObject); | 138 | return new SearchApiResult().setData(jsonObject); |
@@ -33,6 +33,7 @@ import com.yoho.search.service.service.SearchCommonService; | @@ -33,6 +33,7 @@ import com.yoho.search.service.service.SearchCommonService; | ||
33 | import com.yoho.search.service.service.helper.AggProductListHelper; | 33 | import com.yoho.search.service.service.helper.AggProductListHelper; |
34 | import com.yoho.search.service.service.helper.FunctionScoreSearchHelper; | 34 | import com.yoho.search.service.service.helper.FunctionScoreSearchHelper; |
35 | import com.yoho.search.service.service.helper.SearchCommonHelper; | 35 | import com.yoho.search.service.service.helper.SearchCommonHelper; |
36 | +import com.yoho.search.service.service.helper.SearchLikeHelper; | ||
36 | import com.yoho.search.service.service.helper.SearchServiceHelper; | 37 | import com.yoho.search.service.service.helper.SearchServiceHelper; |
37 | import com.yoho.search.service.service.helper.SearchSortHelper; | 38 | import com.yoho.search.service.service.helper.SearchSortHelper; |
38 | import com.yoho.search.service.servicenew.ISearchLikeService; | 39 | import com.yoho.search.service.servicenew.ISearchLikeService; |
@@ -57,7 +58,7 @@ public class SearchLikeServiceImpl implements ISearchLikeService { | @@ -57,7 +58,7 @@ public class SearchLikeServiceImpl implements ISearchLikeService { | ||
57 | @Autowired | 58 | @Autowired |
58 | private AggProductListHelper aggProductListHelper; | 59 | private AggProductListHelper aggProductListHelper; |
59 | @Autowired | 60 | @Autowired |
60 | - private SearchLikeCommonService searchLikeCommonService; | 61 | + private SearchLikeHelper searchLikeHelper; |
61 | 62 | ||
62 | @Override | 63 | @Override |
63 | public SearchApiResult searchLike(Map<String, String> paramMap) { | 64 | public SearchApiResult searchLike(Map<String, String> paramMap) { |
@@ -67,7 +68,7 @@ public class SearchLikeServiceImpl implements ISearchLikeService { | @@ -67,7 +68,7 @@ public class SearchLikeServiceImpl implements ISearchLikeService { | ||
67 | return new SearchApiResult().setCode(400).setMessage("请输入SKN"); | 68 | return new SearchApiResult().setCode(400).setMessage("请输入SKN"); |
68 | } | 69 | } |
69 | // 2、获取当前查询的SKN的基本信息 | 70 | // 2、获取当前查询的SKN的基本信息 |
70 | - JSONObject productInfoInEs = searchLikeCommonService.getProductInfoInEs(productSkn); | 71 | + JSONObject productInfoInEs = searchLikeHelper.getProductInfoInEs(productSkn); |
71 | if (productInfoInEs == null) { | 72 | if (productInfoInEs == null) { |
72 | return new SearchApiResult().setCode(400).setMessage("SKN不存在"); | 73 | return new SearchApiResult().setCode(400).setMessage("SKN不存在"); |
73 | } | 74 | } |
@@ -103,7 +104,7 @@ public class SearchLikeServiceImpl implements ISearchLikeService { | @@ -103,7 +104,7 @@ public class SearchLikeServiceImpl implements ISearchLikeService { | ||
103 | dataMap.put("page_total", 1); | 104 | dataMap.put("page_total", 1); |
104 | dataMap.put("page_size", pageSize); | 105 | dataMap.put("page_size", pageSize); |
105 | dataMap.put("total", productList.size()); | 106 | dataMap.put("total", productList.size()); |
106 | - dataMap.put("product_info", searchLikeCommonService.genProductInfoResult(productInfoInEs)); | 107 | + dataMap.put("product_info", searchLikeHelper.genProductInfoResult(productInfoInEs)); |
107 | dataMap.put("product_list", productList); | 108 | dataMap.put("product_list", productList); |
108 | return new SearchApiResult().setData(dataMap); | 109 | return new SearchApiResult().setData(dataMap); |
109 | } | 110 | } |
@@ -233,7 +234,7 @@ public class SearchLikeServiceImpl implements ISearchLikeService { | @@ -233,7 +234,7 @@ public class SearchLikeServiceImpl implements ISearchLikeService { | ||
233 | if (!isInBrand) { | 234 | if (!isInBrand) { |
234 | minimumShouldMatch = "40%"; | 235 | minimumShouldMatch = "40%"; |
235 | } | 236 | } |
236 | - return searchLikeCommonService.genSearchLikeQueryBuilder(query, minimumShouldMatch, productFeatureFactor); | 237 | + return searchLikeHelper.genSearchLikeQueryBuilder(query, minimumShouldMatch, productFeatureFactor); |
237 | } | 238 | } |
238 | 239 | ||
239 | private List<String> getGenderInfo(String gender) { | 240 | private List<String> getGenderInfo(String gender) { |
@@ -247,7 +248,7 @@ public class SearchLikeServiceImpl implements ISearchLikeService { | @@ -247,7 +248,7 @@ public class SearchLikeServiceImpl implements ISearchLikeService { | ||
247 | } | 248 | } |
248 | 249 | ||
249 | private BoolQueryBuilder genBoolQueryBuilder(JSONObject productInfoInEs, Map<String, String> paramMap, List<String> notProductSkns, boolean isInBrand) { | 250 | private BoolQueryBuilder genBoolQueryBuilder(JSONObject productInfoInEs, Map<String, String> paramMap, List<String> notProductSkns, boolean isInBrand) { |
250 | - BoolQueryBuilder boolFilter = searchLikeCommonService.genDefaultQueryBuilder(notProductSkns); | 251 | + BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultQueryBuilder(notProductSkns); |
251 | // 1)设置此SKN相关的过滤条件 | 252 | // 1)设置此SKN相关的过滤条件 |
252 | String gender = productInfoInEs.getString("gender"); | 253 | String gender = productInfoInEs.getString("gender"); |
253 | List<String> genderList = this.getGenderInfo(gender); | 254 | List<String> genderList = this.getGenderInfo(gender); |
-
Please register or login to post a comment