Authored by hugufei

Merge branch 'recall_config' into 0510

... ... @@ -3,6 +3,7 @@ package com.yoho.search.recall.beans.helper;
import com.yoho.search.base.utils.DateUtil;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.core.personalized.models.SortBrand;
import com.yoho.search.recall.config.SpecialShopConstants;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
... ... @@ -14,6 +15,7 @@ import java.util.List;
public class ExtendFilterHelper {
/**
* 流量补偿的过滤器
*
... ... @@ -24,6 +26,7 @@ public class ExtendFilterHelper {
filter.must(QueryBuilders.termQuery(ProductIndexEsField.flowType, "1"));
filter.mustNot(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50));
filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y"));
filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.shopId, SpecialShopConstants.QXJS_SHOP_ID));
return filter;
}
... ... @@ -37,6 +40,7 @@ public class ExtendFilterHelper {
filter.must(QueryBuilders.termQuery(ProductIndexEsField.toAddScore, "Y"));
filter.mustNot(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50));
filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y"));
filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.shopId, SpecialShopConstants.QXJS_SHOP_ID));
return filter;
}
... ... @@ -221,6 +225,7 @@ public class ExtendFilterHelper {
filter.should(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y"));
//filter.should(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50));
filter.should(QueryBuilders.termsQuery(ProductIndexEsField.storeShowStatus, Arrays.asList("3", "4")));
filter.should(QueryBuilders.termQuery(ProductIndexEsField.shopId, SpecialShopConstants.QXJS_SHOP_ID));
return filter;
}
... ...
package com.yoho.search.recall.config;
import java.util.Arrays;
import java.util.List;
public class SpecialShopConstants {
public static final List<Integer> DOWNGRADE_SHOPIDS = Arrays.asList(3504);
public static final float DOWNGRADE_SHOPID_WEIGHT = 0.5f;
}
... ...
... ... @@ -6,7 +6,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.yoho.search.common.utils.SearchKeyWordUtils;
import com.yoho.search.recall.config.SpecialShopConstants;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.common.lucene.search.function.CombineFunction;
... ... @@ -151,6 +151,8 @@ public class FunctionScoreSearchHelper {
if(StringUtils.isNotBlank(query)){
scorers.add(searchScorerFactory.getCsBrandKeyWordScorer(query));
}
// 7、添加特殊店铺的打分器
scorers.add(searchScorerFactory.getSpecialShopScorer(SpecialShopConstants.DOWNGRADE_SHOPIDS, SpecialShopConstants.DOWNGRADE_SHOPID_WEIGHT));
return scorers;
}
... ...
... ... @@ -114,4 +114,9 @@ public class SearchScorerFactory {
public IScorer getCsBrandKeyWordScorer(String query) {
return new CsBrandKeyWordScorer(query);
}
// 获取CsBrandKeyWord的打分器
public IScorer getSpecialShopScorer(List<Integer> shopIds,float weight) {
return new SpecialShopScorer(shopIds,weight);
}
}
... ...
package com.yoho.search.service.scorer.impl;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.models.YohoFilterFunctionBuilders;
import com.yoho.search.service.scorer.IScorer;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
import java.util.List;
public class SpecialShopScorer implements IScorer {
private List<Integer> shopIds;
private float weight;
public SpecialShopScorer(List<Integer> shopIds, float weight) {
this.shopIds = shopIds;
this.weight = weight;
}
@Override
public void addScorer(YohoFilterFunctionBuilders yohoFilterFunctionBuilders) {
yohoFilterFunctionBuilders.add(QueryBuilders.termsQuery(ProductIndexEsField.shopId, shopIds), ScoreFunctionBuilders.weightFactorFunction(weight));
}
}
... ...
... ... @@ -11,6 +11,7 @@ import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.core.es.utils.SearchFieldUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.models.SearchSort;
import com.yoho.search.recall.config.SpecialShopConstants;
import com.yoho.search.service.base.SearchCommonService;
import com.yoho.search.service.base.SearchRequestParams;
import com.yoho.search.service.base.index.BrandIndexBaseService;
... ... @@ -27,8 +28,6 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder.FilterFunctionBuilder;
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders;
... ... @@ -178,10 +177,7 @@ public class ShopListServiceImpl implements IShopListService {
}
//店铺搜索屏蔽【球鞋集市】
Integer qxjsShopId = 3504;
if(yohoShopIds.contains(qxjsShopId)){
yohoShopIds.remove(qxjsShopId);
}
yohoShopIds.removeAll(SpecialShopConstants.DOWNGRADE_SHOPIDS);
// 获取有货状态为1的店铺
Map<String, Map<String, Object>> yohoShopMap = this.queryYohoValidShopMap(yohoShopIds);
... ...