Authored by hugufei

添加拆分

... ... @@ -48,10 +48,12 @@ public class SearchLikeSecneController {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
int viewNum = MapUtils.getIntValue(paramMap, "viewNum", 10);
int uid = MapUtils.getIntValue(paramMap, "uid", 0);
if (uid>0 && uid % 1024 < 512) {
paramMap.put("use_yoho_image", "true");
SearchApiResult result;
if (uid>0 && (uid % 1024 < 512)) {
result = searchLikeInShopService.searchLikeInShopWithYohoImage(paramMap);
}else{
result = searchLikeInShopService.searchLikeInShop(paramMap);
}
SearchApiResult result = searchLikeInShopService.searchLikeInShop(paramMap);
return searchLikeHelper.buildSearchApiResultWithViewNum(result, viewNum);
}
... ... @@ -61,10 +63,12 @@ public class SearchLikeSecneController {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
int viewNum = MapUtils.getIntValue(paramMap, "viewNum", 10);
int uid = MapUtils.getIntValue(paramMap, "uid", 0);
if (uid>0 && uid % 1024 < 512) {
paramMap.put("use_yoho_image", "true");
SearchApiResult result;
if (uid>0 && (uid % 1024 < 512)) {
result = searchLikeNotInShopService.searchLikeSimilarSknNotInShopWithYohoImage(paramMap);
}else{
result = searchLikeNotInShopService.searchLikeSimilarSknNotInShop(paramMap);
}
SearchApiResult result = searchLikeNotInShopService.searchLikeSimilarSknNotInShop(paramMap);
return searchLikeHelper.buildSearchApiResultWithViewNum(result, viewNum);
}
... ...
... ... @@ -12,7 +12,6 @@ import com.yoho.search.service.helper.ProductListHelper;
import com.yoho.search.service.index.BigdataSimilarSknIndexBaseService;
import com.yoho.search.service.index.ProductIndexBaseService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
... ... @@ -49,14 +48,24 @@ public class SearchLikeInShopService {
@Autowired
private BigdataSimilarSknIndexBaseService bigdataSimilarSknIndexBaseService;
@SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_IN_SHOP_NEW", includeParams = {"product_skn"})
public SearchApiResult searchLikeInShop(Map<String, String> paramMap) {
return innerSearchLikeInShop(paramMap, false);
}
@SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_IN_SHOP_NEW_B", includeParams = {"product_skn"})
public SearchApiResult searchLikeInShopWithYohoImage(Map<String, String> paramMap) {
return innerSearchLikeInShop(paramMap, true);
}
/**
* 店铺内推荐
*
* @param paramMap
* @return
*/
@SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_IN_SHOP_NEW", includeParams = {"product_skn", "use_yoho_image"})
public SearchApiResult searchLikeInShop(Map<String, String> paramMap) {
private SearchApiResult innerSearchLikeInShop(Map<String, String> paramMap, boolean use_yoho_image) {
try {
// 1、获取参数
String productSkn = paramMap.get(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN);
... ... @@ -73,7 +82,6 @@ public class SearchLikeInShopService {
//4、获取similarskn
BigdataSimilarSknIndexBO bigdataSimilarSkn = bigdataSimilarSknIndexBaseService.querySimilarSkn(productSkn);
boolean use_yoho_image = MapUtils.getBooleanValue(paramMap, "use_yoho_image", false);
// 5、设置SearchParams
List<SearchParam> searchParams = new ArrayList<SearchParam>();
... ...
... ... @@ -12,7 +12,6 @@ import com.yoho.search.service.helper.ProductListHelper;
import com.yoho.search.service.index.BigdataSimilarSknIndexBaseService;
import com.yoho.search.service.index.ProductIndexBaseService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
... ... @@ -44,8 +43,17 @@ public class SearchLikeNotInShopService {
@Autowired
private BigdataSimilarSknIndexBaseService bigdataSimilarSknIndexBaseService;
@SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_NOT_IN_SHOP_SIMILAR_NEW", includeParams = {"product_skn", "use_yoho_image"})
@SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_NOT_IN_SHOP_SIMILAR_NEW", includeParams = {"product_skn"})
public SearchApiResult searchLikeSimilarSknNotInShop(Map<String, String> paramMap) {
return innersearchLikeSimilarSknNotInShop(paramMap, false);
}
@SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_NOT_IN_SHOP_SIMILAR_NEW_B", includeParams = {"product_skn"})
public SearchApiResult searchLikeSimilarSknNotInShopWithYohoImage(Map<String, String> paramMap) {
return innersearchLikeSimilarSknNotInShop(paramMap, true);
}
private SearchApiResult innersearchLikeSimilarSknNotInShop(Map<String, String> paramMap, boolean use_yoho_image) {
try {
// 1、获取参数
String productSkn = paramMap.get(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN);
... ... @@ -62,7 +70,6 @@ public class SearchLikeNotInShopService {
//4、获取similarskn
BigdataSimilarSknIndexBO bigdataSimilarSkn = bigdataSimilarSknIndexBaseService.querySimilarSkn(productSkn);
boolean use_yoho_image = MapUtils.getBooleanValue(paramMap, "use_yoho_image", false);
//5、构造searchParams
List<SearchParam> searchParams = new ArrayList<>();
... ... @@ -135,7 +142,7 @@ public class SearchLikeNotInShopService {
* @param productSkns
* @return
*/
private SearchParam builderSimilarSknSearchParam(JSONObject productInfoInEs, List<String> productSkns){
private SearchParam builderSimilarSknSearchParam(JSONObject productInfoInEs, List<String> productSkns) {
// 1、设置SearchParam
SearchParam searchParam = new SearchParam();
// 2)设置query和filter
... ...