Showing
6 changed files
with
25 additions
and
37 deletions
@@ -81,14 +81,10 @@ public class GoodProductSceneService { | @@ -81,14 +81,10 @@ public class GoodProductSceneService { | ||
81 | private static final String collect_product_skn = "collect_product_skn"; | 81 | private static final String collect_product_skn = "collect_product_skn"; |
82 | 82 | ||
83 | public SearchApiResult goodProductList(Map<String, String> paramMap) throws Exception { | 83 | public SearchApiResult goodProductList(Map<String, String> paramMap) throws Exception { |
84 | -// if (searchCommonHelper.isDebugUser(paramMap)) { | ||
85 | -// logger.warn("goodProductList param is : [{}]", paramMap.toString()); | ||
86 | -// } | ||
87 | - // 去除product_skn参数先,为了兼容 | 84 | + // 0、去除product_skn参数先,为了兼容 |
88 | if (paramMap.containsKey("product_skn")) { | 85 | if (paramMap.containsKey("product_skn")) { |
89 | paramMap.remove("product_skn"); | 86 | paramMap.remove("product_skn"); |
90 | } | 87 | } |
91 | - | ||
92 | // 1、检测分页参数 | 88 | // 1、检测分页参数 |
93 | int pageSize = StringUtils.isBlank(paramMap.get("viewNum")) ? 30 : Integer.parseInt(paramMap.get("viewNum")); | 89 | int pageSize = StringUtils.isBlank(paramMap.get("viewNum")) ? 30 : Integer.parseInt(paramMap.get("viewNum")); |
94 | int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page")); | 90 | int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page")); |
@@ -112,10 +108,6 @@ public class GoodProductSceneService { | @@ -112,10 +108,6 @@ public class GoodProductSceneService { | ||
112 | // 3、再根据品类和品牌推荐SKN | 108 | // 3、再根据品类和品牌推荐SKN |
113 | List<String> recommondSkns = this.recommondSknsBySortAndBrandInfo(sortAndBrandInfo, paramMap, view_product_skns, cart_productskns, collect_product_skns); | 109 | List<String> recommondSkns = this.recommondSknsBySortAndBrandInfo(sortAndBrandInfo, paramMap, view_product_skns, cart_productskns, collect_product_skns); |
114 | 110 | ||
115 | -// if (searchCommonHelper.isDebugUser(paramMap)) { | ||
116 | -// logger.warn("goodProductList recommondSkns is : [{}]", recommondSkns); | ||
117 | -// } | ||
118 | - | ||
119 | // 4、构造搜索参数 | 111 | // 4、构造搜索参数 |
120 | SearchParam searchParam = new SearchParam(); | 112 | SearchParam searchParam = new SearchParam(); |
121 | BoolQueryBuilder boolFilter = searchServiceHelper.constructFilterBuilder(paramMap, null); | 113 | BoolQueryBuilder boolFilter = searchServiceHelper.constructFilterBuilder(paramMap, null); |
@@ -160,12 +160,15 @@ public class SearchLikeHelper { | @@ -160,12 +160,15 @@ public class SearchLikeHelper { | ||
160 | */ | 160 | */ |
161 | public BoolQueryBuilder genDefaultSearchLikeFilter(List<String> notProductSkns, boolean isGlobal) { | 161 | public BoolQueryBuilder genDefaultSearchLikeFilter(List<String> notProductSkns, boolean isGlobal) { |
162 | BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); | 162 | BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); |
163 | - boolFilter.mustNot(QueryBuilders.termsQuery("isSeckill", "Y")); | 163 | + boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isSeckill, "Y")); |
164 | boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isFobbiden, 1)); | 164 | boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isFobbiden, 1)); |
165 | - boolFilter.must(QueryBuilders.termQuery("status", 1)); | ||
166 | - boolFilter.must(QueryBuilders.termQuery("isOutlets", 2)); | ||
167 | - boolFilter.must(QueryBuilders.termQuery("attribute", 1)); | ||
168 | - boolFilter.must(QueryBuilders.rangeQuery("storageNum").gte(1)); | 165 | + boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.attribute, 2)); |
166 | + | ||
167 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.status, 1)); | ||
168 | + boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.storageNum).gte(1)); | ||
169 | + | ||
170 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isOutlets, 2)); | ||
171 | + | ||
169 | if (notProductSkns != null && !notProductSkns.isEmpty()) { | 172 | if (notProductSkns != null && !notProductSkns.isEmpty()) { |
170 | boolFilter.mustNot(QueryBuilders.termsQuery("productSkn", notProductSkns)); | 173 | boolFilter.mustNot(QueryBuilders.termsQuery("productSkn", notProductSkns)); |
171 | } | 174 | } |
@@ -11,12 +11,9 @@ import org.apache.commons.lang.StringUtils; | @@ -11,12 +11,9 @@ import org.apache.commons.lang.StringUtils; | ||
11 | import org.elasticsearch.index.query.BoolQueryBuilder; | 11 | import org.elasticsearch.index.query.BoolQueryBuilder; |
12 | import org.elasticsearch.index.query.QueryBuilder; | 12 | import org.elasticsearch.index.query.QueryBuilder; |
13 | import org.elasticsearch.index.query.QueryBuilders; | 13 | import org.elasticsearch.index.query.QueryBuilders; |
14 | -import org.elasticsearch.search.builder.SearchSourceBuilder; | ||
15 | import org.elasticsearch.search.sort.SortBuilder; | 14 | import org.elasticsearch.search.sort.SortBuilder; |
16 | import org.elasticsearch.search.sort.SortBuilders; | 15 | import org.elasticsearch.search.sort.SortBuilders; |
17 | import org.elasticsearch.search.sort.SortOrder; | 16 | import org.elasticsearch.search.sort.SortOrder; |
18 | -import org.slf4j.Logger; | ||
19 | -import org.slf4j.LoggerFactory; | ||
20 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
21 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
22 | 19 | ||
@@ -25,7 +22,6 @@ import com.yoho.search.base.utils.ISearchConstants; | @@ -25,7 +22,6 @@ import com.yoho.search.base.utils.ISearchConstants; | ||
25 | import com.yoho.search.common.cache.SearchCacheFactory; | 22 | import com.yoho.search.common.cache.SearchCacheFactory; |
26 | import com.yoho.search.common.cache.model.SearchCache; | 23 | import com.yoho.search.common.cache.model.SearchCache; |
27 | import com.yoho.search.core.es.model.SearchParam; | 24 | import com.yoho.search.core.es.model.SearchParam; |
28 | -import com.yoho.search.core.es.utils.SearchParamUtils; | ||
29 | import com.yoho.search.models.SearchApiResult; | 25 | import com.yoho.search.models.SearchApiResult; |
30 | import com.yoho.search.service.base.SearchCacheService; | 26 | import com.yoho.search.service.base.SearchCacheService; |
31 | import com.yoho.search.service.base.SearchCommonService; | 27 | import com.yoho.search.service.base.SearchCommonService; |
@@ -42,8 +38,6 @@ import com.yoho.search.service.helper.SearchCommonHelper; | @@ -42,8 +38,6 @@ import com.yoho.search.service.helper.SearchCommonHelper; | ||
42 | @Service | 38 | @Service |
43 | public class SearchLikeInShopService { | 39 | public class SearchLikeInShopService { |
44 | 40 | ||
45 | - private static final Logger logger = LoggerFactory.getLogger(SearchLikeInShopService.class); | ||
46 | - | ||
47 | @Autowired | 41 | @Autowired |
48 | private SearchCommonService searchCommonService; | 42 | private SearchCommonService searchCommonService; |
49 | @Autowired | 43 | @Autowired |
@@ -92,18 +86,14 @@ public class SearchLikeInShopService { | @@ -92,18 +86,14 @@ public class SearchLikeInShopService { | ||
92 | // 4、设置第一步SearchParam | 86 | // 4、设置第一步SearchParam |
93 | List<SearchParam> searchParams = new ArrayList<SearchParam>(); | 87 | List<SearchParam> searchParams = new ArrayList<SearchParam>(); |
94 | searchParams.add(this.builderSearchParam(productInfoInEs, Arrays.asList(productSkn), pageSize)); | 88 | searchParams.add(this.builderSearchParam(productInfoInEs, Arrays.asList(productSkn), pageSize)); |
95 | - for (SearchParam searchParam : searchParams) { | ||
96 | - SearchSourceBuilder searchSourceBuilder = SearchParamUtils.genSearchSourceBuilderFromSearchParam(searchParam); | ||
97 | - logger.warn("searchSourceBuilder is [{}]",searchSourceBuilder.toString()); | ||
98 | - } | ||
99 | 89 | ||
100 | // 5、从缓存中获取数据,有则直接返回 | 90 | // 5、从缓存中获取数据,有则直接返回 |
101 | String productIndexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX; | 91 | String productIndexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX; |
102 | JSONObject cacheObject = searchCacheService.getJSONObjectFromCache(searchLikeSearchCache, productIndexName, searchParams); | 92 | JSONObject cacheObject = searchCacheService.getJSONObjectFromCache(searchLikeSearchCache, productIndexName, searchParams); |
103 | if (cacheObject != null) { | 93 | if (cacheObject != null) { |
104 | - //return new SearchApiResult().setData(cacheObject); | 94 | + return new SearchApiResult().setData(cacheObject); |
105 | } | 95 | } |
106 | - | 96 | + |
107 | // 6、获取搜索结果[截取条数] | 97 | // 6、获取搜索结果[截取条数] |
108 | List<Map<String, Object>> tempProductList = searchLikeHelper.queryProductList(searchParams); | 98 | List<Map<String, Object>> tempProductList = searchLikeHelper.queryProductList(searchParams); |
109 | if (tempProductList.size() > pageSize) { | 99 | if (tempProductList.size() > pageSize) { |
@@ -130,7 +120,7 @@ public class SearchLikeInShopService { | @@ -130,7 +120,7 @@ public class SearchLikeInShopService { | ||
130 | // 1、设置SearchParam | 120 | // 1、设置SearchParam |
131 | SearchParam searchParam = new SearchParam(); | 121 | SearchParam searchParam = new SearchParam(); |
132 | // 2)设置query和filter | 122 | // 2)设置query和filter |
133 | - searchParam.setQuery(this.builderQueryBuilder(productInfoInEs, "10%")); | 123 | + searchParam.setQuery(this.builderQueryBuilder(productInfoInEs, "20%")); |
134 | searchParam.setFiter(this.builderFilterBuilder(productInfoInEs, productSkns)); | 124 | searchParam.setFiter(this.builderFilterBuilder(productInfoInEs, productSkns)); |
135 | // 3、设置排序规则[按打分排序] | 125 | // 3、设置排序规则[按打分排序] |
136 | List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>(); | 126 | List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>(); |
@@ -152,8 +142,8 @@ public class SearchLikeInShopService { | @@ -152,8 +142,8 @@ public class SearchLikeInShopService { | ||
152 | // 1)设置此SKN相关的性别过滤条件 | 142 | // 1)设置此SKN相关的性别过滤条件 |
153 | String gender = productInfoInEs.getString("gender"); | 143 | String gender = productInfoInEs.getString("gender"); |
154 | List<String> genderList = searchLikeHelper.getGenderInfo(gender); | 144 | List<String> genderList = searchLikeHelper.getGenderInfo(gender); |
155 | - if (genderList != null) { | ||
156 | - boolFilter.must(QueryBuilders.termsQuery("gender", genderList.toArray(new String[genderList.size()]))); | 145 | + if (genderList != null && !genderList.isEmpty()) { |
146 | + boolFilter.must(QueryBuilders.termsQuery("gender",genderList)); | ||
157 | } | 147 | } |
158 | // 2)设置品牌或店铺信息 | 148 | // 2)设置品牌或店铺信息 |
159 | Integer brandId = productInfoInEs.getInteger("brandId"); | 149 | Integer brandId = productInfoInEs.getInteger("brandId"); |
@@ -119,7 +119,7 @@ public class SearchLikeNotInShopService { | @@ -119,7 +119,7 @@ public class SearchLikeNotInShopService { | ||
119 | // 1、设置SearchParam | 119 | // 1、设置SearchParam |
120 | SearchParam searchParam = new SearchParam(); | 120 | SearchParam searchParam = new SearchParam(); |
121 | // 2)设置query和filter | 121 | // 2)设置query和filter |
122 | - searchParam.setQuery(this.builderQueryBuilder(productInfoInEs, inSmallSort ? "40%" : "20%")); | 122 | + searchParam.setQuery(this.builderQueryBuilder(productInfoInEs, inSmallSort ? "30%" : "20%")); |
123 | searchParam.setFiter(this.builderFilterBuilder(productInfoInEs, productSkns, inSmallSort)); | 123 | searchParam.setFiter(this.builderFilterBuilder(productInfoInEs, productSkns, inSmallSort)); |
124 | // 3、设置排序规则[按打分排序] | 124 | // 3、设置排序规则[按打分排序] |
125 | List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>(); | 125 | List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>(); |
@@ -141,8 +141,8 @@ public class SearchLikeNotInShopService { | @@ -141,8 +141,8 @@ public class SearchLikeNotInShopService { | ||
141 | // 1)设置此SKN相关的性别过滤条件 | 141 | // 1)设置此SKN相关的性别过滤条件 |
142 | String gender = productInfoInEs.getString("gender"); | 142 | String gender = productInfoInEs.getString("gender"); |
143 | List<String> genderList = searchLikeHelper.getGenderInfo(gender); | 143 | List<String> genderList = searchLikeHelper.getGenderInfo(gender); |
144 | - if (genderList != null) { | ||
145 | - boolFilter.must(QueryBuilders.termsQuery("gender", genderList.toArray(new String[genderList.size()]))); | 144 | + if (genderList != null && !genderList.isEmpty()) { |
145 | + boolFilter.must(QueryBuilders.termsQuery("gender", genderList)); | ||
146 | } | 146 | } |
147 | // 2)设置品牌或店铺信息 | 147 | // 2)设置品牌或店铺信息 |
148 | Integer brandId = productInfoInEs.getInteger("brandId"); | 148 | Integer brandId = productInfoInEs.getInteger("brandId"); |
@@ -263,11 +263,11 @@ public class SimilarProductServiceImpl extends BaseService implements ISimilarPr | @@ -263,11 +263,11 @@ public class SimilarProductServiceImpl extends BaseService implements ISimilarPr | ||
263 | private BoolQueryBuilder getDefaultBoolQueryBuilder() { | 263 | private BoolQueryBuilder getDefaultBoolQueryBuilder() { |
264 | BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); | 264 | BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); |
265 | boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isSeckill, "Y")); | 265 | boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isSeckill, "Y")); |
266 | - // boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isGlobal, | ||
267 | - // "Y")); | 266 | + boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isFobbiden, 1)); |
267 | + boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.attribute, 2)); | ||
268 | + | ||
268 | boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.status, 1)); | 269 | boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.status, 1)); |
269 | boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isOutlets, 2)); | 270 | boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isOutlets, 2)); |
270 | - boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.attribute, 1)); | ||
271 | boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.storageNum).gte(1)); | 271 | boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.storageNum).gte(1)); |
272 | // 非断码 | 272 | // 非断码 |
273 | boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).lt(50)); | 273 | boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).lt(50)); |
@@ -241,10 +241,13 @@ public class SknImageVectorsServiceImpl implements ISknImageVectorsService, Appl | @@ -241,10 +241,13 @@ public class SknImageVectorsServiceImpl implements ISknImageVectorsService, Appl | ||
241 | BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); | 241 | BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); |
242 | boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isSeckill, "Y")); | 242 | boolFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.isSeckill, "Y")); |
243 | boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isFobbiden, 1)); | 243 | boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isFobbiden, 1)); |
244 | + boolFilter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.attribute, 2)); | ||
245 | + | ||
244 | boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.status, 1)); | 246 | boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.status, 1)); |
245 | - boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isOutlets, 2)); | ||
246 | - boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.attribute, 1)); | ||
247 | boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.storageNum).gte(1)); | 247 | boolFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.storageNum).gte(1)); |
248 | + | ||
249 | + boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.isOutlets, 2)); | ||
250 | + | ||
248 | boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, productSkns)); | 251 | boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, productSkns)); |
249 | return boolFilter; | 252 | return boolFilter; |
250 | } | 253 | } |
-
Please register or login to post a comment