Authored by hugufei

fix bug

... ... @@ -13,6 +13,8 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.sort.SortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -40,6 +42,8 @@ import com.yoho.search.service.scorer.personal.PersonalVectorFeatureSearch;
@Service
public class CommonSceneProductListService {
private static final Logger logger = LoggerFactory.getLogger(CommonSceneProductListService.class);
@Autowired
private CommonPageRecallService commonRecallSceneService;
@Autowired
... ... @@ -137,7 +141,7 @@ public class CommonSceneProductListService {
results.put("product_list", this.getProductListFromCache(productInfoMapResult, commonRecallResult, page, viewNum));
} else {
// 8、其他页码使用CommonRecallParamService去查询
results.put("product_list", this.queryProductListForOtherPageIndex(paramMap, commonRecallResult, page - recallMaxPage, viewNum));
results.put("product_list", this.queryProductListForOtherPageIndex(paramMap, commonRecallResult, page - recallMaxPage, viewNum).getData());
}
return new SearchApiResult().setData(results);
}
... ... @@ -151,18 +155,23 @@ public class CommonSceneProductListService {
* @return
*/
private SearchApiResult queryProductListForOtherPageIndex(Map<String, String> paramMap, CommonRecallResult commonRecallResult, int realPage, int viewNum) {
// 1、其他页码使用CommonRecallParamService去查询
CommonRecallParam commonRecallParam = new CommonRecallParam(paramMap, 0, realPage, viewNum);
// 2、前面几个已经召回的需要排除
BoolQueryBuilder extendMustFilter = QueryBuilders.boolQuery();
extendMustFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, commonRecallResult.toSknList()));
commonRecallParam.setExtendMustFilter(extendMustFilter);
// 3、构造sort
List<SortBuilder<?>> sortBuilders = new ArrayList<SortBuilder<?>>();
sortBuilders.add(SortBuilders.fieldSort(ProductIndexEsField.sevendayMoney).order(SortOrder.DESC));
commonRecallParam.setSortBuilders(sortBuilders);
// 4、执行查询
return cacheAbleServiceHelper.queryProductListByRecallParam(commonRecallParam);
try {
// 1、其他页码使用CommonRecallParamService去查询
CommonRecallParam commonRecallParam = new CommonRecallParam(paramMap, 0, realPage, viewNum);
// 2、前面几个已经召回的需要排除
BoolQueryBuilder extendMustFilter = QueryBuilders.boolQuery();
extendMustFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, commonRecallResult.toSknList()));
commonRecallParam.setExtendMustFilter(extendMustFilter);
// 3、构造sort
List<SortBuilder<?>> sortBuilders = new ArrayList<SortBuilder<?>>();
sortBuilders.add(SortBuilders.fieldSort(ProductIndexEsField.sevendayMoney).order(SortOrder.DESC));
commonRecallParam.setSortBuilders(sortBuilders);
// 4、执行查询
return cacheAbleServiceHelper.queryProductListByRecallParam(commonRecallParam);
} catch (Exception e) {
logger.error(e.getMessage(),e);
return new SearchApiResult().setData(new ArrayList<>());
}
}
private long getTotalPage(long total, int viewNum) {
... ... @@ -211,9 +220,6 @@ public class CommonSceneProductListService {
}
}
Collections.sort(commonRecallResult.getRecallSknList());
for (CommonRecallSkn commonRecallSkn : commonRecallResult.getRecallSknList()) {
System.out.println(commonRecallSkn.score());
}
return commonRecallResult;
}
}
... ...