Authored by hugufei

添加品牌品类向量加载的日志

... ... @@ -5,8 +5,11 @@ import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.core.personalized.models.SortBrand;
import com.yoho.search.recall.scene.beans.persional.QueryUserPersionalFactorBean;
import com.yoho.search.service.base.SearchCommonService;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -22,6 +25,8 @@ import java.util.concurrent.TimeUnit;
@Component
public class SortBrandVectorCacheBean {
private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL");
@Autowired
private SearchCommonService searchCommonService;
... ... @@ -37,6 +42,7 @@ public class SortBrandVectorCacheBean {
public List<Double> queryBrandSortVector(SortBrand sortBrand) {
try {
if (sortBrandVector == null || sortBrandVector.isEmpty()) {
RECALL_NEW_LOGGER.warn("sortBrandVector is empty,please check........");
return new ArrayList<>();
}
return sortBrandVector.get(sortBrand.key());
... ... @@ -46,26 +52,34 @@ public class SortBrandVectorCacheBean {
}
private Map<String, List<Double>> loadAllSortBrandVectors() {
SearchParam searchParam = new SearchParam();
searchParam.setSize(20000);
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_BIGDATASORTBRANDVECTOR, searchParam);
Map<String, List<Double>> result = new HashMap<>();
for (Map<String, Object> sortBrandVector : searchResult.getResultList()) {
try {
int middleSortId = MapUtils.getIntValue(sortBrandVector, "middleSortId", 0);
int brandId = MapUtils.getIntValue(sortBrandVector, "brandId", 0);
String vector = MapUtils.getString(sortBrandVector, "vector", "[]");
List<Double> vectorArray = JSON.parseArray(vector, Double.class);
if (middleSortId == 0 || brandId == 0 || vectorArray.isEmpty()) {
continue;
}
SortBrand sortBrand = new SortBrand(middleSortId, brandId);
result.put(sortBrand.key(), vectorArray);
} catch (Exception e) {
try {
RECALL_NEW_LOGGER.info("loadAllSortBrandVectors begin ........");
long begin = System.currentTimeMillis();
SearchParam searchParam = new SearchParam();
searchParam.setSize(20000);
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_BIGDATASORTBRANDVECTOR, searchParam);
Map<String, List<Double>> result = new HashMap<>();
for (Map<String, Object> sortBrandVector : searchResult.getResultList()) {
try {
int middleSortId = MapUtils.getIntValue(sortBrandVector, "middleSortId", 0);
int brandId = MapUtils.getIntValue(sortBrandVector, "brandId", 0);
String vector = MapUtils.getString(sortBrandVector, "vector", "[]");
List<Double> vectorArray = JSON.parseArray(vector, Double.class);
if (middleSortId == 0 || brandId == 0 || vectorArray.isEmpty()) {
continue;
}
SortBrand sortBrand = new SortBrand(middleSortId, brandId);
result.put(sortBrand.key(), vectorArray);
} catch (Exception e) {
}
}
RECALL_NEW_LOGGER.info("loadAllSortBrandVectors end,size is[{}],cost is[{}]",result.size(),System.currentTimeMillis()-begin);
return result;
}catch (Exception e){
RECALL_NEW_LOGGER.error("loadAllSortBrandVectors fail"+e.getMessage(),e);
return null;
}
return result;
}
}
... ...