Authored by hugufei

fix searchLikeSimilarSknNotInShop

... ... @@ -5,6 +5,7 @@ import com.yoho.search.base.utils.CollectionUtils;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.base.utils.Transfer;
import com.yoho.search.common.cache.aop.SearchCacheAble;
import com.yoho.search.common.productlist.aop.ProductListWithSknRetention;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.dal.model.SimilarSkn;
import com.yoho.search.models.SearchApiResult;
... ... @@ -54,7 +55,6 @@ public class BigdataSimilarSknService {
return results;
}
@SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_NOT_IN_SHOP_SIMILAR", includeParams = { "product_skn", "viewNum" })
public SearchApiResult searchLikeSimilarSknNotInShop(Map<String, String> paramMap) {
try {
... ... @@ -90,7 +90,7 @@ public class BigdataSimilarSknService {
searchParams.add(this.builderSimilarSknSearchParam(productInfoInEs, diffShopActionSimilarSkns, true));
//5.3)文字兜底[性别+不同店铺+文字相似性]
searchParams.add(this.builderCharactersSearchParam(productInfoInEs, Arrays.asList(productSkn), pageSize, true));
searchParams.add( searchLikeHelper.builderSearchLikeNotInShopCharactersSearchParam(productInfoInEs, Arrays.asList(productSkn), pageSize,true));
// 6、获取搜索结果
List<List<Map<String, Object>>> queryResults = searchLikeHelper.queryProductLists(searchParams);
... ... @@ -157,10 +157,6 @@ public class BigdataSimilarSknService {
return results;
}
private SearchParam builderCharactersSearchParam(JSONObject productInfoInEs, List<String> notProductSkns, int pageSize, boolean inSameSort) {
return searchLikeHelper.builderSearchLikeNotInShopCharactersSearchParam(productInfoInEs, notProductSkns, pageSize,inSameSort);
}
/**
* 构建SimilarSknSearchParam[考虑productSkns为空的情况]
... ...
... ... @@ -286,36 +286,6 @@ public class SearchLikeHelper {
return results;
}
public Map<String, Object> searchBigdataSimilarSkn(String productSkn) {
SearchParam searchParam = new SearchParam();
BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, productSkn));
searchParam.setFiter(boolFilter);
searchParam.setAggregationBuilders(null);
searchParam.setSize(1);
String productIndexName = ISearchConstants.INDEX_NAME_BIGDATA_SIMILAR_SKN_INDEX;
SearchResult searchResult = searchCommonService.doSearch(productIndexName, searchParam);
if (searchResult == null) {
return null;
}
List<Map<String, Object>> similarSknResults = searchResult.getResultList();
if (CollectionUtils.isEmpty(similarSknResults) || similarSknResults.get(0) == null) {
return null;
}
return similarSknResults.get(0);
}
/**
* 找相似相关的匹配打分策略
* @param productFeatureFactor
* @return
*/
public QueryBuilder genProductFeatureQueryBuilder(String productFeatureFactor) {
return functionScoreSearchHelper.buildFunctionScoreQueryBuildWithProductFeature(QueryBuilders.matchAllQuery(), productFeatureFactor);
}
/**
* 店铺外按文字找相似
* @param productInfoInEs
... ...