Authored by hugufei

兜底使用人气和点击率做a/b

package com.yoho.search.recall.scene.beans.helper;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
public class StrategyHelper {
public static boolean isCommonStrategy(StrategyEnum strategy) {
return strategy.equals(StrategyEnum.COMMON_CTR_VALUE) || strategy.equals(StrategyEnum.COMMON_HEAT_VALUE);
}
}
package com.yoho.search.recall.scene.beans.helper;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
public class StrategyHelper {
public static boolean isCommonStrategy(StrategyEnum strategy) {
return strategy.equals(StrategyEnum.COMMON_CTR_VALUE) || strategy.equals(StrategyEnum.COMMON_HEAT_VALUE);
}
}
... ...
package com.yoho.search.recall.scene.beans.strategy.impls;
import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper;
import com.yoho.search.recall.scene.beans.strategy.IStrategy;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.constants.CacheTimeConstants;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.sort.SortBuilder;
/**
* 直通车的召回
*
* @author gufei.hu
*
*/
public class CommonCtrValueStrategy implements IStrategy {
private int size;
public CommonCtrValueStrategy(int size) {
this.size = size;
}
@Override
public StrategyEnum strategtEnum() {
return StrategyEnum.COMMON_CTR_VALUE;
}
@Override
public QueryBuilder extendFilter() {
return null;
}
@Override
public SortBuilder<?> sortBuilder() {
return SortBuilderHelper.getCtrValueDescSort();
}
@Override
public int size() {
return size;
}
@Override
public int cacheTimeInMinute() {
return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME;
}
@Override
public String strategyCacheKey() {
StringBuilder sb = defaultStrategyKey();
return sb.toString();
}
}
package com.yoho.search.recall.scene.beans.strategy.impls;
import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper;
import com.yoho.search.recall.scene.beans.strategy.IStrategy;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.constants.CacheTimeConstants;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.sort.SortBuilder;
/**
* 直通车的召回
*
* @author gufei.hu
*
*/
public class CommonCtrValueStrategy implements IStrategy {
private int size;
public CommonCtrValueStrategy(int size) {
this.size = size;
}
@Override
public StrategyEnum strategtEnum() {
return StrategyEnum.COMMON_CTR_VALUE;
}
@Override
public QueryBuilder extendFilter() {
return null;
}
@Override
public SortBuilder<?> sortBuilder() {
return SortBuilderHelper.getCtrValueDescSort();
}
@Override
public int size() {
return size;
}
@Override
public int cacheTimeInMinute() {
return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME;
}
@Override
public String strategyCacheKey() {
StringBuilder sb = defaultStrategyKey();
return sb.toString();
}
}
... ...
package com.yoho.search.recall.scene.beans.strategy.impls;
import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper;
import com.yoho.search.recall.scene.beans.strategy.IStrategy;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.constants.CacheTimeConstants;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.sort.SortBuilder;
/**
* 按人气兜底的召回
*
* @author gufei.hu
*
*/
public class CommonHeatValueStrategy implements IStrategy {
private int size;
public CommonHeatValueStrategy(int size) {
this.size = size;
}
@Override
public StrategyEnum strategtEnum() {
return StrategyEnum.COMMON_HEAT_VALUE;
}
@Override
public QueryBuilder extendFilter() {
return null;
}
@Override
public SortBuilder<?> sortBuilder() {
return SortBuilderHelper.getHeatValueDescSort();
}
@Override
public int size() {
return size;
}
@Override
public int cacheTimeInMinute() {
return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME;
}
@Override
public String strategyCacheKey() {
StringBuilder sb = defaultStrategyKey();
return sb.toString();
}
}
package com.yoho.search.recall.scene.beans.strategy.impls;
import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper;
import com.yoho.search.recall.scene.beans.strategy.IStrategy;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.constants.CacheTimeConstants;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.sort.SortBuilder;
/**
* 按人气兜底的召回
*
* @author gufei.hu
*
*/
public class CommonHeatValueStrategy implements IStrategy {
private int size;
public CommonHeatValueStrategy(int size) {
this.size = size;
}
@Override
public StrategyEnum strategtEnum() {
return StrategyEnum.COMMON_HEAT_VALUE;
}
@Override
public QueryBuilder extendFilter() {
return null;
}
@Override
public SortBuilder<?> sortBuilder() {
return SortBuilderHelper.getHeatValueDescSort();
}
@Override
public int size() {
return size;
}
@Override
public int cacheTimeInMinute() {
return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME;
}
@Override
public String strategyCacheKey() {
StringBuilder sb = defaultStrategyKey();
return sb.toString();
}
}
... ...
package com.yoho.search.recall.scene.beans.strategy.impls;
import com.yoho.search.recall.scene.beans.helper.ExtendFilterHelper;
import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper;
import com.yoho.search.recall.scene.beans.strategy.IStrategy;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.constants.CacheTimeConstants;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.sort.SortBuilder;
/**
* 直通车的召回
*
* @author gufei.hu
*
*/
public class CommonRecallValueStrategy implements IStrategy {
private int size;
public CommonRecallValueStrategy(int size) {
this.size = size;
}
@Override
public StrategyEnum strategtEnum() {
return StrategyEnum.COMMON_RECALL_VALUE;
}
@Override
public QueryBuilder extendFilter() {
return ExtendFilterHelper.commonRecallValueFilter();
}
@Override
public SortBuilder<?> sortBuilder() {
return SortBuilderHelper.getRandomSort();
}
@Override
public int size() {
return size;
}
@Override
public int cacheTimeInMinute() {
return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME;
}
@Override
public String strategyCacheKey() {
StringBuilder sb = defaultStrategyKey();
return sb.toString();
}
}
package com.yoho.search.recall.scene.beans.strategy.impls;
import com.yoho.search.recall.scene.beans.helper.ExtendFilterHelper;
import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper;
import com.yoho.search.recall.scene.beans.strategy.IStrategy;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.constants.CacheTimeConstants;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.sort.SortBuilder;
/**
* 真正兜底的召回
*
* @author gufei.hu
*
*/
public class CommonStrategy implements IStrategy {
private int size;
public CommonStrategy(int size) {
this.size = size;
}
@Override
public StrategyEnum strategtEnum() {
return StrategyEnum.COMMON;
}
@Override
public QueryBuilder extendFilter() {
return ExtendFilterHelper.commonFilter();
}
@Override
public SortBuilder<?> sortBuilder() {
return SortBuilderHelper.getHeatValueDescSort();
}
@Override
public int size() {
return size;
}
@Override
public int cacheTimeInMinute() {
return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME;
}
@Override
public String strategyCacheKey() {
StringBuilder sb = defaultStrategyKey();
return sb.toString();
}
}