Authored by hugufei

优化随机load的方式

Showing 17 changed files with 404 additions and 148 deletions
package com.yoho.search.service.index;
import com.alibaba.fastjson.JSON;
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.dal.model.CsRecallConfigCommon;
import com.yoho.search.common.SearchCommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class CsRecallConfigCommonIndexBaseService {
@Autowired
private SearchCommonService searchCommonService;
public List<CsRecallConfigCommon> queryAll(){
SearchParam searchParam = new SearchParam();
searchParam.setOffset(0);
searchParam.setSize(10000);
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_CS_RECALL_CONFIG_COMMON, searchParam);
List<Map<String, Object>> results = searchResult.getResultList();
List<CsRecallConfigCommon> list = new ArrayList<>();
for (Map<String, Object> result : results) {
list.add(JSON.parseObject(JSON.toJSONString(result),CsRecallConfigCommon.class));
}
return list;
}
}
package com.yoho.search.service.index;
import com.alibaba.fastjson.JSON;
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.dal.model.CsRecallConfigProduct;
import com.yoho.search.common.SearchCommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class CsRecallConfigProductIndexBaseService {
@Autowired
private SearchCommonService searchCommonService;
public List<CsRecallConfigProduct> queryAll(){
SearchParam searchParam = new SearchParam();
searchParam.setOffset(0);
searchParam.setSize(10000);
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_CS_RECALL_CONFIG_PRODUCT, searchParam);
List<Map<String, Object>> results = searchResult.getResultList();
List<CsRecallConfigProduct> list = new ArrayList<>();
for (Map<String, Object> result : results) {
list.add(JSON.parseObject(JSON.toJSONString(result),CsRecallConfigProduct.class));
}
return list;
}
}
... ... @@ -68,8 +68,6 @@ public class CutpriceConfigIndexBaseService {
searchParam.setOffset(0);
searchParam.setSize(300);
SearchSourceBuilder ss = SearchParamUtils.genSearchSourceBuilderFromSearchParam(searchParam);
System.out.println(ss);
//4、执行es搜索
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_CUT_PRICE_CONFIG, searchParam);
... ...
... ... @@ -4,7 +4,7 @@ import com.yoho.search.core.personalized.models.SortBrand;
import com.yoho.search.service.recall.strategy.IStrategy;
import com.yoho.search.service.recall.strategy.SortBrandType;
import com.yoho.search.service.recall.config.RecallConfigService;
import com.yoho.search.service.recall.config.SortBrandSknCount;
import com.yoho.search.service.recall.config.model.SortBrandSknCount;
import com.yoho.search.service.recall.models.common.ParamQueryFilter;
import com.yoho.search.service.recall.models.req.RecallRequest;
import com.yoho.search.service.recall.models.req.UserRecallRequest;
... ...
... ... @@ -5,7 +5,7 @@ import com.yoho.search.base.utils.Transfer;
import com.yoho.search.core.personalized.models.PersonalizedSearch;
import com.yoho.search.core.personalized.models.SortPriceAreas;
import com.yoho.search.service.recall.helper.W2vFeatureCalculator;
import com.yoho.search.service.recall.config.RecallConfigConstants;
import com.yoho.search.service.recall.helper.RecallConfigConstants;
import com.yoho.search.service.recall.config.RecallConfigService;
import com.yoho.search.service.recall.models.personal.UserFeatureFactor;
import com.yoho.search.service.base.SknBaseInfoBaseService;
... ...
... ... @@ -113,7 +113,7 @@ public class QueryUserPersionalFactorBean {
//9、如果个性化结果为空,再取配置的品类品牌数据
if (userPersonalFactor.isUserPersonalFactorEmpty()) {
int configSortBrandCount = recallConfigService.querySortBrandConfigCount(userRecallRequest, SortBrandType.CONFIG_SORT_BRAND, 12);
List<SortBrand> configSortBrandList = recallConfigService.queryConfigSortBrandList(pageFactor, pageSortBrandKeys, filterSortBrandKeys, configSortBrandCount);
List<SortBrand> configSortBrandList = recallConfigService.randomConfigSortBrand(pageFactor, pageSortBrandKeys, filterSortBrandKeys, configSortBrandCount);
userPersonalFactor.setConfigSortBrandList(configSortBrandList);
}
... ...
package com.yoho.search.service.recall.config;
import com.yoho.search.base.utils.Transfer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public abstract class AbstractCacheConfigBean<ESObject, CacheObject> {
private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL");
private ScheduledExecutorService schedule = Executors.newSingleThreadScheduledExecutor();
private List<CacheObject> cacheList = new ArrayList<>();
private Transfer<ESObject, CacheObject> transfer;
@PostConstruct
void init() {
this.transfer = getTransfer();
schedule.scheduleAtFixedRate(() -> loadCache(), 0, 1, TimeUnit.MINUTES);
}
protected void loadCache() {
String functionName = this.getClass().getSimpleName() + " loadCache ";
try {
long begin = System.currentTimeMillis();
RECALL_NEW_LOGGER.info(functionName + "begin ........");
List<ESObject> esObjectList = this.queryAllFromEs();
List<CacheObject> temp = new ArrayList<>();
for (ESObject esObject : esObjectList) {
CacheObject cacheObject = transfer.transfer(esObject);
temp.add(cacheObject);
}
this.cacheList = temp;
RECALL_NEW_LOGGER.info(functionName + "success,cacheList size is[{}], cost is[{}] ", cacheList.size(), System.currentTimeMillis() - begin);
} catch (Exception e) {
RECALL_NEW_LOGGER.error(functionName + "error,exception is:" + e.getMessage(), e);
}
}
protected abstract Transfer<ESObject, CacheObject> getTransfer();
protected abstract List<ESObject> queryAllFromEs();
protected List<CacheObject> getCopyCacheListAndRandom() {
List<CacheObject> copyList = new ArrayList<>(this.cacheList);
Collections.shuffle(copyList);
return copyList;
}
}
... ...
package com.yoho.search.service.recall.config;
import com.alibaba.fastjson.JSON;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.Transfer;
import com.yoho.search.common.SearchCommonService;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.dal.model.CsRecallConfigBrand;
import com.yoho.search.service.recall.models.personal.PagePersonalFactor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@Component
class ConfigBrandService extends AbstractCacheConfigBean<CsRecallConfigBrand,Integer>{
@Autowired
private SearchCommonService searchCommonService;
@Override
protected Transfer<CsRecallConfigBrand, Integer> getTransfer() {
return new Transfer<CsRecallConfigBrand, Integer>() {
@Override
public Integer transfer(CsRecallConfigBrand csRecallConfigBrand) {
return csRecallConfigBrand.getBrandId();
}
};
}
@Override
protected List<CsRecallConfigBrand> queryAllFromEs() {
SearchParam searchParam = new SearchParam();
searchParam.setOffset(0);
searchParam.setSize(10000);
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_CS_RECALL_CONFIG_BRAND, searchParam);
List<Map<String, Object>> results = searchResult.getResultList();
List<CsRecallConfigBrand> list = new ArrayList<>();
for (Map<String, Object> result : results) {
list.add(JSON.parseObject(JSON.toJSONString(result), CsRecallConfigBrand.class));
}
return list;
}
/**
* 随机获取页面中,属于配置的品牌
*
* @param pageFactor
* @param size
* @return
*/
public List<Integer> randomConfigBrand(PagePersonalFactor pageFactor, int size) {
if (size <= 0 || CollectionUtils.isEmpty(pageFactor.getBrandIds())) {
return new ArrayList<>();
}
List<Integer> copyList =this.getCopyCacheListAndRandom();
List<Integer> pageBrandIds = pageFactor.getBrandIds();
List<Integer> results = new ArrayList<>();
for (Integer brandId : copyList) {
if (results.size() >= size) {
break;
}
if (!pageBrandIds.contains(brandId)) {
continue;
}
results.add(brandId);
}
return results;
}
}
... ...
... ... @@ -2,59 +2,38 @@ package com.yoho.search.service.recall.config;
import com.alibaba.fastjson.JSON;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.Transfer;
import com.yoho.search.common.SearchCommonService;
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.dal.model.CsRecallConfigSortBrand;
import com.yoho.search.service.recall.models.personal.PagePersonalFactor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Component
class ConfigSortBrandService {
private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL");
class ConfigSortBrandService extends AbstractCacheConfigBean<CsRecallConfigSortBrand, SortBrand> {
@Autowired
private SearchCommonService searchCommonService;
private List<SortBrand> configSortBrandsCache = new ArrayList<>();
private ScheduledExecutorService schedule = Executors.newSingleThreadScheduledExecutor();
@PostConstruct
void init() {
schedule.scheduleAtFixedRate(() -> loadConfigSortBrandsCache(), 0, 1, TimeUnit.MINUTES);
}
private void loadConfigSortBrandsCache() {
try {
RECALL_NEW_LOGGER.info("loadConfigSortBrandsCache begin ........");
long begin = System.currentTimeMillis();
List<SortBrand> tempCache = new ArrayList<>();
List<CsRecallConfigSortBrand> csRecallConfigSortBrands = queryAll();
for (CsRecallConfigSortBrand csRecallConfigSortBrand : csRecallConfigSortBrands) {
@Override
protected Transfer<CsRecallConfigSortBrand, SortBrand> getTransfer() {
return new Transfer<CsRecallConfigSortBrand, SortBrand>() {
@Override
public SortBrand transfer(CsRecallConfigSortBrand csRecallConfigSortBrand) {
Integer misort = csRecallConfigSortBrand.getSortId();
Integer brandId = csRecallConfigSortBrand.getBrandId();
tempCache.add(new SortBrand(misort, brandId));
return new SortBrand(misort, brandId);
}
configSortBrandsCache = tempCache;
RECALL_NEW_LOGGER.info("loadConfigSortBrandsCache success,configSortBrandsCache size is[{}], cost is[{}] ", configSortBrandsCache.size(), System.currentTimeMillis() - begin);
} catch (Exception e) {
RECALL_NEW_LOGGER.error("loadConfigSortBrandsCache error,exception is:" + e.getMessage(), e);
}
};
}
private List<CsRecallConfigSortBrand> queryAll(){
@Override
protected List<CsRecallConfigSortBrand> queryAllFromEs() {
SearchParam searchParam = new SearchParam();
searchParam.setOffset(0);
searchParam.setSize(10000);
... ... @@ -62,22 +41,26 @@ class ConfigSortBrandService {
List<Map<String, Object>> results = searchResult.getResultList();
List<CsRecallConfigSortBrand> list = new ArrayList<>();
for (Map<String, Object> result : results) {
list.add(JSON.parseObject(JSON.toJSONString(result),CsRecallConfigSortBrand.class));
list.add(JSON.parseObject(JSON.toJSONString(result), CsRecallConfigSortBrand.class));
}
return list;
}
/**
* 随机获取size个品类品牌
* 随机获取页面中,属于配置的品牌品类
*
* @param pageFactor
* @param pageSortBrandKeys
* @param filterSortBrandKeys
* @param size
* @return
*/
private List<SortBrand> randomConfigSortBrands(List<SortBrand> configSortBrands, Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, int size) {
List<SortBrand> copyList = new ArrayList<>(configSortBrands);
Collections.shuffle(copyList);
public List<SortBrand> randomConfigSortBrand(PagePersonalFactor pageFactor, Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, int size) {
if (size <= 0) {
return new ArrayList<>();
}
List<SortBrand> copyList = this.getCopyCacheListAndRandom();
List<SortBrand> results = new ArrayList<>();
for (SortBrand sortBrand : copyList) {
if (results.size() >= size) {
... ... @@ -91,23 +74,8 @@ class ConfigSortBrandService {
}
results.add(sortBrand);
}
System.out.println(JSON.toJSONString(results));
return results;
}
/**
* 随机获取页面中,属于配置的品牌品类
*
* @param pageFactor
* @param pageSortBrandKeys
* @param filterSortBrandKeys
* @param size
* @return
*/
public List<SortBrand> queryConfigSortBrand(PagePersonalFactor pageFactor, Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, int size) {
if (size <= 0) {
return new ArrayList<>();
}
return this.randomConfigSortBrands(this.configSortBrandsCache, pageSortBrandKeys, filterSortBrandKeys, size);
}
}
... ...
package com.yoho.search.service.recall.config;
import com.alibaba.fastjson.JSON;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.Transfer;
import com.yoho.search.common.SearchCommonService;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.dal.model.CsRecallConfigSortPrice;
import com.yoho.search.service.recall.models.personal.PagePersonalFactor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Component
class ConfigSortPriceService extends AbstractCacheConfigBean<CsRecallConfigSortPrice,CsRecallConfigSortPrice>{
@Autowired
private SearchCommonService searchCommonService;
@Override
protected Transfer<CsRecallConfigSortPrice, CsRecallConfigSortPrice> getTransfer() {
return new Transfer<CsRecallConfigSortPrice, CsRecallConfigSortPrice>() {
@Override
public CsRecallConfigSortPrice transfer(CsRecallConfigSortPrice csRecallConfigSortPrice) {
return csRecallConfigSortPrice;
}
};
}
@Override
protected List<CsRecallConfigSortPrice> queryAllFromEs() {
SearchParam searchParam = new SearchParam();
searchParam.setOffset(0);
searchParam.setSize(10000);
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_CS_RECALL_CONFIG_SORT_PRICE, searchParam);
List<Map<String, Object>> results = searchResult.getResultList();
List<CsRecallConfigSortPrice> list = new ArrayList<>();
for (Map<String, Object> result : results) {
list.add(JSON.parseObject(JSON.toJSONString(result), CsRecallConfigSortPrice.class));
}
return list;
}
/**
* 随机获取页面中,属于配置的品类价格带
*
* @param pageFactor
* @param size
* @return
*/
public List<CsRecallConfigSortPrice> randomConfigSortPrice(PagePersonalFactor pageFactor, int size) {
if (size <= 0 || CollectionUtils.isEmpty(pageFactor.getMisortIds())) {
return new ArrayList<>();
}
List<CsRecallConfigSortPrice> copyList = this.getCopyCacheListAndRandom();
List<CsRecallConfigSortPrice> results = new ArrayList<>();
for (CsRecallConfigSortPrice sortPrice : copyList) {
if (results.size() >= size) {
break;
}
if(!pageFactor.getMisortIds().contains(sortPrice.getSortId())){
continue;
}
results.add(sortPrice);
}
return results;
}
}
... ...
... ... @@ -2,6 +2,8 @@ package com.yoho.search.service.recall.config;
import com.alibaba.fastjson.JSON;
import com.yoho.search.core.personalized.models.SortBrand;
import com.yoho.search.dal.model.CsRecallConfigSortPrice;
import com.yoho.search.service.recall.config.model.SortBrandSknCount;
import com.yoho.search.service.recall.models.personal.PagePersonalFactor;
import com.yoho.search.service.recall.models.req.UserRecallRequest;
import com.yoho.search.service.recall.strategy.SortBrandType;
... ... @@ -25,6 +27,10 @@ public class RecallConfigService {
private SizeIntervalService sizeIntervalService;
@Autowired
private ConfigSortBrandService configSortBrandService;
@Autowired
private ConfigBrandService configBrandService;
@Autowired
private ConfigSortPriceService configSortPriceService;
private static int legallValue(int value, int min, int max) {
value = Math.min(value, max);
... ... @@ -103,19 +109,37 @@ public class RecallConfigService {
}
/**
* 随机获取configSortBrandCount数量
* 随机获取配置的品类品牌
*
* @param pageFactor
* @param filterSortBrandKeys
* @param configSortBrandCount
* @return
*/
public List<SortBrand> queryConfigSortBrandList(PagePersonalFactor pageFactor, Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, int configSortBrandCount) {
return configSortBrandService.queryConfigSortBrand(pageFactor, pageSortBrandKeys, filterSortBrandKeys, configSortBrandCount);
public List<SortBrand> randomConfigSortBrand(PagePersonalFactor pageFactor, Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, int configSortBrandCount) {
return configSortBrandService.randomConfigSortBrand(pageFactor, pageSortBrandKeys, filterSortBrandKeys, configSortBrandCount);
}
/**
* 随机获取配置的品牌
*
* @param pageFactor
* @param count
* @return
*/
public List<Integer> randomConfigBrand(PagePersonalFactor pageFactor, int count) {
return configBrandService.randomConfigBrand(pageFactor, count);
}
public static void main(String[] args) {
System.out.println(legallValue(-1, 0, 30));
/**
* 随机获取配置的品类价格带
*
* @param pageFactor
* @param count
* @return
*/
public List<CsRecallConfigSortPrice> randomSortPrice(PagePersonalFactor pageFactor, int count) {
return configSortPriceService.randomConfigSortPrice(pageFactor, count);
}
}
... ...
package com.yoho.search.service.recall.config;
import com.alibaba.fastjson.JSON;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.common.SearchCommonService;
import com.yoho.search.common.utils.MapSizeUtils;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.dal.model.CsRecallConfigCommon;
import com.yoho.search.service.index.CsRecallConfigCommonIndexBaseService;
import com.yoho.search.service.recall.config.model.SizeInterval;
import com.yoho.search.service.recall.helper.RecallConfigConstants;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -10,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
... ... @@ -18,12 +25,12 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Component
class SizeIntervalService {
class SizeIntervalService{
private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL");
@Autowired
private CsRecallConfigCommonIndexBaseService csRecallConfigCommonIndexBaseService;
private SearchCommonService searchCommonService;
private ScheduledExecutorService schedule = Executors.newSingleThreadScheduledExecutor();
... ... @@ -38,7 +45,7 @@ class SizeIntervalService {
try {
RECALL_NEW_LOGGER.info("loadRecallConfigCommonCache ........");
long begin = System.currentTimeMillis();
List<CsRecallConfigCommon> configList = csRecallConfigCommonIndexBaseService.queryAll();
List<CsRecallConfigCommon> configList = queryAll();
Map<String, Map<Integer, SizeInterval>> tempCache = new HashMap<>();
for (CsRecallConfigCommon csRecallConfigCommon : configList) {
//1、类型判断
... ... @@ -60,6 +67,19 @@ class SizeIntervalService {
}
}
private List<CsRecallConfigCommon> queryAll(){
SearchParam searchParam = new SearchParam();
searchParam.setOffset(0);
searchParam.setSize(10000);
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_CS_RECALL_CONFIG_COMMON, searchParam);
List<Map<String, Object>> results = searchResult.getResultList();
List<CsRecallConfigCommon> list = new ArrayList<>();
for (Map<String, Object> result : results) {
list.add(JSON.parseObject(JSON.toJSONString(result),CsRecallConfigCommon.class));
}
return list;
}
/**
* @param pageId
* @param isDefaultOrder
... ...
package com.yoho.search.service.recall.config;
import com.alibaba.fastjson.JSON;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.common.SearchCommonService;
import com.yoho.search.common.utils.MapSizeUtils;
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.dal.model.CsRecallConfigProduct;
import com.yoho.search.service.index.CsRecallConfigProductIndexBaseService;
import com.yoho.search.service.recall.config.model.SortBrandSknCount;
import com.yoho.search.service.recall.helper.RecallConfigConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
... ... @@ -23,7 +30,7 @@ class SortBrandSknCountService {
private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL");
@Autowired
private CsRecallConfigProductIndexBaseService csRecallConfigProductIndexBaseService;
private SearchCommonService searchCommonService;
private Map<String, Map<Integer, SortBrandSknCount>> recallSknCountConfigCache = new HashMap<>();
... ... @@ -38,7 +45,7 @@ class SortBrandSknCountService {
try {
RECALL_NEW_LOGGER.info("loadRecallSknCountConfigCache begin ........");
long begin = System.currentTimeMillis();
List<CsRecallConfigProduct> configList = csRecallConfigProductIndexBaseService.queryAll();
List<CsRecallConfigProduct> configList = queryAll();
Map<String, Map<Integer, SortBrandSknCount>> tempCache = new HashMap<>();
for (CsRecallConfigProduct productConfig : configList) {
//1、类型判断
... ... @@ -65,6 +72,20 @@ class SortBrandSknCountService {
}
}
private List<CsRecallConfigProduct> queryAll(){
SearchParam searchParam = new SearchParam();
searchParam.setOffset(0);
searchParam.setSize(10000);
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_CS_RECALL_CONFIG_PRODUCT, searchParam);
List<Map<String, Object>> results = searchResult.getResultList();
List<CsRecallConfigProduct> list = new ArrayList<>();
for (Map<String, Object> result : results) {
list.add(JSON.parseObject(JSON.toJSONString(result),CsRecallConfigProduct.class));
}
return list;
}
private String buildConfiKey(String configType, String configTypeId) {
if (configType.equalsIgnoreCase(RecallConfigConstants.SORT)) {
return this.buildCacheKey(RecallConfigConstants.SORT, configTypeId);
... ...
package com.yoho.search.service.recall.config.model;
public class SizeInterval {
private int size;
private int interval;
public SizeInterval(int size, int interval) {
this.size = size;
this.interval = interval;
}
public int getSize() {
return size;
}
public int getInterval() {
return interval;
}
}
... ...
package com.yoho.search.service.recall.config.model;
public class SortBrandSknCount {
private int newShelve;
private int promotion;
private int reducePrice;
private int ctrValue;
private int heatValue;
private int random;
public int getNewShelve() {
return newShelve;
}
public void setNewShelve(int newShelve) {
this.newShelve = newShelve;
}
public int getPromotion() {
return promotion;
}
public void setPromotion(int promotion) {
this.promotion = promotion;
}
public int getReducePrice() {
return reducePrice;
}
public void setReducePrice(int reducePrice) {
this.reducePrice = reducePrice;
}
public int getCtrValue() {
return ctrValue;
}
public void setCtrValue(int ctrValue) {
this.ctrValue = ctrValue;
}
public int getHeatValue() {
return heatValue;
}
public void setHeatValue(int heatValue) {
this.heatValue = heatValue;
}
public int getRandom() {
return random;
}
public void setRandom(int random) {
this.random = random;
}
}
... ...
package com.yoho.search.service.recall.helper;
public class RecallConfigConstants {
public static final int USER_MAX_RECALL_COUNT = 300;//用户最大的召回数量
public static final int DEFAULT_PAGE_ID = 0;
public static final int DEFAULT_PAGE_ID_GUANZHU = 10000;
public static final String SORT = "SORT";
public static final String BRAND = "BRAND";
public static final String SORT_BRAND = "SORT_BRAND";
}
... ...
... ... @@ -9,9 +9,6 @@ public class RecallSknInfo implements Serializable{
private Integer productSkn;
private String recallType;
public RecallSknInfo() {
}
public RecallSknInfo(Integer productSkn, String recallType) {
this.productSkn = productSkn;
this.recallType = recallType;
... ... @@ -21,15 +18,9 @@ public class RecallSknInfo implements Serializable{
return productSkn;
}
public void setProductSkn(Integer productSkn) {
this.productSkn = productSkn;
}
public String getRecallType() {
return recallType;
}
public void setRecallType(String recallType) {
this.recallType = recallType;
}
}
... ...