|
|
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();
|
|
|
}
|
|
|
|
|
|
} |