Authored by hugufei

找相似支持返回ufo商品

@@ -183,15 +183,13 @@ public class SearchLikeHelper { @@ -183,15 +183,13 @@ public class SearchLikeHelper {
183 * 183 *
184 * @return 184 * @return
185 */ 185 */
186 - public BoolQueryBuilder genDefaultSearchLikeFilter(List<String> notProductSkns, boolean isGlobal) { 186 + public BoolQueryBuilder genDefaultSearchLikeFilter(List<String> notProductSkns, boolean isGlobal, boolean isUfo) {
187 BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); 187 BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
188 boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isSeckill, "Y")); 188 boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isSeckill, "Y"));
189 boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isFobbiden, 1)); 189 boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isFobbiden, 1));
190 boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.attribute, 2)); 190 boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.attribute, 2));
191 -  
192 boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.status, 1)); 191 boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.status, 1));
193 boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.storageNum).gte(1)); 192 boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.storageNum).gte(1));
194 -  
195 boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isOutlets, 2)); 193 boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isOutlets, 2));
196 194
197 if (notProductSkns != null && !notProductSkns.isEmpty()) { 195 if (notProductSkns != null && !notProductSkns.isEmpty()) {
@@ -199,10 +197,12 @@ public class SearchLikeHelper { @@ -199,10 +197,12 @@ public class SearchLikeHelper {
199 } 197 }
200 if (isGlobal) { 198 if (isGlobal) {
201 boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.isGlobal, "Y")); 199 boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.isGlobal, "Y"));
  200 + } else if (isUfo) {
  201 + boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.isUfo, "Y"));
202 } else { 202 } else {
203 boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isGlobal, "Y")); 203 boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isGlobal, "Y"));
204 - }  
205 boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isUfo, "Y")); 204 boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isUfo, "Y"));
  205 + }
206 return boolFilter; 206 return boolFilter;
207 } 207 }
208 208
@@ -53,12 +53,6 @@ public class SearchLikeInShopService { @@ -53,12 +53,6 @@ public class SearchLikeInShopService {
53 @Autowired 53 @Autowired
54 private BigdataSimilarSknIndexBaseService bigdataSimilarSknIndexBaseService; 54 private BigdataSimilarSknIndexBaseService bigdataSimilarSknIndexBaseService;
55 55
56 -  
57 - @SearchCacheAble(cacheInMinute = 60, cacheName = "SEARCH_LIKE_IN_SHOP_OLD", includeParams = {"product_skn"})  
58 - public SearchApiResult searchLikeInShop(Map<String, String> paramMap) {  
59 - return innerSearchLikeInShop(paramMap, false);  
60 - }  
61 -  
62 @SearchCacheAble(cacheInMinute = 60, cacheName = "SEARCH_LIKE_IN_SHOP", includeParams = {"product_skn"}) 56 @SearchCacheAble(cacheInMinute = 60, cacheName = "SEARCH_LIKE_IN_SHOP", includeParams = {"product_skn"})
63 public SearchApiResult searchLikeInShopWithYohoImage(Map<String, String> paramMap) { 57 public SearchApiResult searchLikeInShopWithYohoImage(Map<String, String> paramMap) {
64 return innerSearchLikeInShop(paramMap, true); 58 return innerSearchLikeInShop(paramMap, true);
@@ -196,9 +190,7 @@ public class SearchLikeInShopService { @@ -196,9 +190,7 @@ public class SearchLikeInShopService {
196 private BoolQueryBuilder builderSearchLikeInShopFilter(JSONObject productInfoInEs, List<String> inProductSkns, boolean needSameSort) { 190 private BoolQueryBuilder builderSearchLikeInShopFilter(JSONObject productInfoInEs, List<String> inProductSkns, boolean needSameSort) {
197 //1) 默认参数 191 //1) 默认参数
198 String productSkn = productInfoInEs.getString(ProductIndexEsField.productSkn); 192 String productSkn = productInfoInEs.getString(ProductIndexEsField.productSkn);
199 - String isGlobalInEs = productInfoInEs.getString(ProductIndexEsField.isGlobal);  
200 - boolean isGlobal = "Y".equalsIgnoreCase(isGlobalInEs);  
201 - BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(Arrays.asList(productSkn), isGlobal); 193 + BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(Arrays.asList(productSkn), false,false);
202 194
203 // 2)设置此SKN相关的性别过滤条件 195 // 2)设置此SKN相关的性别过滤条件
204 String gender = productInfoInEs.getString(ProductIndexEsField.gender); 196 String gender = productInfoInEs.getString(ProductIndexEsField.gender);
@@ -191,9 +191,7 @@ public class SearchLikeNotInShopService { @@ -191,9 +191,7 @@ public class SearchLikeNotInShopService {
191 private BoolQueryBuilder buildSearchLikeNotInShopFilter(JSONObject productInfoInEs, List<String> inProductSkns) { 191 private BoolQueryBuilder buildSearchLikeNotInShopFilter(JSONObject productInfoInEs, List<String> inProductSkns) {
192 //1) 默认参数 192 //1) 默认参数
193 String productSkn = productInfoInEs.getString(ProductIndexEsField.productSkn); 193 String productSkn = productInfoInEs.getString(ProductIndexEsField.productSkn);
194 - String isGlobalInEs = productInfoInEs.getString(ProductIndexEsField.isGlobal);  
195 - boolean isGlobal = "Y".equalsIgnoreCase(isGlobalInEs);  
196 - BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(Arrays.asList(productSkn), isGlobal); 194 + BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(Arrays.asList(productSkn), false,false);
197 195
198 // 2)设置此SKN相关的性别过滤条件 196 // 2)设置此SKN相关的性别过滤条件
199 String gender = productInfoInEs.getString(ProductIndexEsField.gender); 197 String gender = productInfoInEs.getString(ProductIndexEsField.gender);
@@ -65,10 +65,12 @@ public class SearchLikeSceneService { @@ -65,10 +65,12 @@ public class SearchLikeSceneService {
65 65
66 // 4、设置第一步SearchParam 66 // 4、设置第一步SearchParam
67 String isGlobalInEs = productInfoInEs.getString(ProductIndexEsField.isGlobal); 67 String isGlobalInEs = productInfoInEs.getString(ProductIndexEsField.isGlobal);
  68 + String isUfoInEs = productInfoInEs.getString(ProductIndexEsField.isUfo);
68 boolean isGlobal = "Y".equalsIgnoreCase(isGlobalInEs); 69 boolean isGlobal = "Y".equalsIgnoreCase(isGlobalInEs);
  70 + boolean isUfo = "Y".equalsIgnoreCase(isUfoInEs);
69 List<SearchParam> searchParams = new ArrayList<SearchParam>(); 71 List<SearchParam> searchParams = new ArrayList<SearchParam>();
70 - searchParams.add(this.buildSearchParam(productInfoInEs, 5, true, isGlobal));// 固定取同品牌的5个商品  
71 - searchParams.add(this.buildSearchParam(productInfoInEs, pageSize, false, isGlobal)); 72 + searchParams.add(this.buildSearchParam(productInfoInEs, 5, true, isGlobal,isUfo));// 固定取同品牌的5个商品
  73 + searchParams.add(this.buildSearchParam(productInfoInEs, pageSize, false, isGlobal,isUfo));// 取同品牌的5个商品
72 74
73 // 5、获取搜索结果[并截取条数] 75 // 5、获取搜索结果[并截取条数]
74 List<Map<String, Object>> tempProductList = searchLikeHelper.queryProductList(searchParams); 76 List<Map<String, Object>> tempProductList = searchLikeHelper.queryProductList(searchParams);
@@ -103,16 +105,16 @@ public class SearchLikeSceneService { @@ -103,16 +105,16 @@ public class SearchLikeSceneService {
103 * @param isGlobal 105 * @param isGlobal
104 * @return 106 * @return
105 */ 107 */
106 - private SearchParam buildSearchParam(JSONObject productInfoInEs, int limitCount, boolean inBrand, boolean isGlobal) { 108 + private SearchParam buildSearchParam(JSONObject productInfoInEs, int limitCount, boolean inBrand, boolean isGlobal,boolean isUfo) {
107 SearchParam searchParam = new SearchParam(); 109 SearchParam searchParam = new SearchParam();
108 110
109 // 1、构建Query 111 // 1、构建Query
110 - QueryBuilder queryBuilder = this.buildCharsetQueryBuilder(productInfoInEs, inBrand, isGlobal); 112 + QueryBuilder queryBuilder = this.buildCharsetQueryBuilder(productInfoInEs, inBrand, isGlobal,isUfo);
111 searchParam.setQuery(queryBuilder); 113 searchParam.setQuery(queryBuilder);
112 114
113 // 2、设置过滤条件 115 // 2、设置过滤条件
114 List<String> notProductSkns = Arrays.asList(productInfoInEs.getString(ProductIndexEsField.productSkn)); 116 List<String> notProductSkns = Arrays.asList(productInfoInEs.getString(ProductIndexEsField.productSkn));
115 - BoolQueryBuilder booleanQueryBuilder = this.genSearchLikeFilterBuilder(productInfoInEs, notProductSkns, inBrand, isGlobal); 117 + BoolQueryBuilder booleanQueryBuilder = this.genSearchLikeFilterBuilder(productInfoInEs, notProductSkns, inBrand, isGlobal, isUfo);
116 searchParam.setFiter(booleanQueryBuilder); 118 searchParam.setFiter(booleanQueryBuilder);
117 119
118 // 3、设置排序规则[按打分排序] 120 // 3、设置排序规则[按打分排序]
@@ -137,8 +139,8 @@ public class SearchLikeSceneService { @@ -137,8 +139,8 @@ public class SearchLikeSceneService {
137 * @param isGlobal 139 * @param isGlobal
138 * @return 140 * @return
139 */ 141 */
140 - private BoolQueryBuilder genSearchLikeFilterBuilder(JSONObject productInfoInEs, List<String> notProductSkns, boolean isInBrand, boolean isGlobal) {  
141 - BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(notProductSkns, isInBrand ? isGlobal : false);// 前几个是全球购,后面找有货的就好 142 + private BoolQueryBuilder genSearchLikeFilterBuilder(JSONObject productInfoInEs, List<String> notProductSkns, boolean isInBrand, boolean isGlobal,boolean isUfo) {
  143 + BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(notProductSkns, isInBrand ? isGlobal : false,isInBrand ? isUfo : false);// 前几个是全球购,后面找有货的就好
142 // 1)设置此SKN相关的过滤条件 144 // 1)设置此SKN相关的过滤条件
143 String gender = productInfoInEs.getString(ProductIndexEsField.gender); 145 String gender = productInfoInEs.getString(ProductIndexEsField.gender);
144 List<String> genderList = searchLikeHelper.getGenderInfo(gender); 146 List<String> genderList = searchLikeHelper.getGenderInfo(gender);
@@ -177,9 +179,9 @@ public class SearchLikeSceneService { @@ -177,9 +179,9 @@ public class SearchLikeSceneService {
177 * @param isGlobal 179 * @param isGlobal
178 * @return 180 * @return
179 */ 181 */
180 - private QueryBuilder buildCharsetQueryBuilder(JSONObject productInfoInEs, boolean isInBrand, boolean isGlobal) { 182 + private QueryBuilder buildCharsetQueryBuilder(JSONObject productInfoInEs, boolean isInBrand, boolean isGlobal,boolean isUfo){
181 // 1、如果是全球购,则直接用商品名称+品类名称去查 183 // 1、如果是全球购,则直接用商品名称+品类名称去查
182 - if (isGlobal) { 184 + if (isGlobal || isUfo) {
183 String queryString = searchLikeHelper.genGlobalQueryString(productInfoInEs); 185 String queryString = searchLikeHelper.genGlobalQueryString(productInfoInEs);
184 return searchLikeHelper.buildCharsetQueryBuilder(queryString, "25%"); 186 return searchLikeHelper.buildCharsetQueryBuilder(queryString, "25%");
185 } 187 }
@@ -251,7 +253,7 @@ public class SearchLikeSceneService { @@ -251,7 +253,7 @@ public class SearchLikeSceneService {
251 searchParam.setQuery(queryBuilder); 253 searchParam.setQuery(queryBuilder);
252 254
253 // 2、设置过滤条件 255 // 2、设置过滤条件
254 - BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(Arrays.asList(productInfoInEs.getString("productSkn")), false); 256 + BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(Arrays.asList(productInfoInEs.getString("productSkn")), false,false);
255 boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.storeShowStatus, Arrays.asList("1", "2"))); 257 boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.storeShowStatus, Arrays.asList("1", "2")));
256 258
257 // 3、找相似要具体到到中分类或小分类,大分类范围太广 259 // 3、找相似要具体到到中分类或小分类,大分类范围太广