Authored by unknown

fix

... ... @@ -85,11 +85,11 @@ public class AggregationFactoryService {
return new RecommendShopAggregation(shopsIndexBaseService, personalVectorFeatureSearch, paramMap, shopCount);
}
public IAggregation getGroupBrandAggregation(Map<String, String> paramMap, String topHitOrder, int tophitCount) {
public IAggregation getGroupBrandAggregation(String topHitOrder, int tophitCount) {
return new GroupBrandAggregation(brandIndexBaseService, productIndexBaseService, topHitOrder, tophitCount);
}
public IAggregation getGroupShopAggregation(Map<String, String> paramMap, String topHitOrder, int tophitCount) {
public IAggregation getGroupShopAggregation(String topHitOrder, int tophitCount) {
return new GroupShopAggregation(shopsIndexBaseService, productIndexBaseService, topHitOrder, tophitCount);
}
... ...
... ... @@ -19,6 +19,7 @@ import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder;
import com.alibaba.fastjson.JSONArray;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.core.es.agg.AbstractAggregation;
import com.yoho.search.service.utils.SearchRequestParams;
public class SortGroupAggregation extends AbstractAggregation {
... ... @@ -44,7 +45,7 @@ public class SortGroupAggregation extends AbstractAggregation {
TermsBuilder maxAggBuilder = AggregationBuilders.terms("maxAgg").field(ProductIndexEsField.maxSortName).size(100);
TermsBuilder middleAggBuilder = AggregationBuilders.terms("middleAgg").field(ProductIndexEsField.middleSortName).size(100);
TermsBuilder smallAggBuilder = AggregationBuilders.terms("smallAgg").field(ProductIndexEsField.smallSortName).size(100);
if (paramMap.containsKey("needSmallSort") && "1".equals(paramMap.get("needSmallSort"))) {
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_NEEDSMALLSORT) && "1".equals(paramMap.get(SearchRequestParams.PARAM_SEARCH_NEEDSMALLSORT))) {
maxAggBuilder.subAggregation(middleAggBuilder.subAggregation(smallAggBuilder));
} else {
maxAggBuilder.subAggregation(middleAggBuilder);
... ...
... ... @@ -17,7 +17,8 @@ import ch.qos.logback.classic.Logger;
*/
public final class LogUtils {
private static final Logger ROOT_LOGGER = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
@SuppressWarnings("static-access")
private static final Logger ROOT_LOGGER = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
private static final Map<String, Level> sourceLevelMap = new ConcurrentHashMap<>();
... ...
package com.yoho.search.service.searchexplainer;
import com.yoho.search.base.utils.HttpServletRequestUtils;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -9,9 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import com.yoho.search.base.utils.HttpServletRequestUtils;
/**
* Created by ginozhang on 2016/11/16.
... ... @@ -50,7 +52,7 @@ public class SearchExplainerController {
@RequestMapping(value = "/tools/clearExplainCachedData")
@ResponseBody
public Map<String, Object> clearExplainCachedData(HttpServletRequest request) {
public Map<String, Object> clearExplainCachedData() {
try {
searchExplainerService.clearCachedData();
Map<String, Object> map = new HashMap<>();
... ...
... ... @@ -59,6 +59,7 @@ public class AggregationService implements ApplicationEventPublisherAware {
this.publisher = applicationEventPublisher;
}
@SuppressWarnings("unused")
private SearchResult doSearchForAggregation(IAggregation aggregation, SearchParam searchParam) {
SearchParam searchParamClone = searchParam.clone();
return searchCommonService.doSearch(AggregationServiceIndex, searchParamClone);
... ...
... ... @@ -73,7 +73,7 @@ public class SearchServiceHelper {
}
// 4.设置查询字段和比重【AND表示多字段都要匹配,可提高精确度】
this.setDefaultSearchField(queryBuilder, paramMap);
this.setDefaultSearchField(queryBuilder);
if ("or".equalsIgnoreCase(ISearchConstants.SEARCH_OPERATOR)) {
queryBuilder.operator(MatchQueryBuilder.Operator.OR);
queryBuilder.minimumShouldMatch(ISearchConstants.SEARCH_MINIMUM_SHOULD_MATCH);
... ... @@ -104,7 +104,7 @@ public class SearchServiceHelper {
*
* @param queryBuilder
*/
private void setDefaultSearchField(MultiMatchQueryBuilder queryBuilder, Map<String, String> paramMap) {
private void setDefaultSearchField(MultiMatchQueryBuilder queryBuilder) {
List<String> fields = ISearchConstants.SEARCH_DEFAULT_FIELD;
for (String field : fields) {
String[] fieldBoost = field.split("\\^");
... ...
... ... @@ -70,7 +70,7 @@ public class AggRecommendServiceImpl implements IAggRecommendService {
try {
// 1、获取核心参数
boolean needPreAggregation = true;
String aggWithParamBrand = paramMap.get("aggWithParamBrand");
String aggWithParamBrand = paramMap.get(SearchRequestParams.PARAM_SEARCH_AGG_WITH_PARAM_BRAND);
if ("Y".equals(aggWithParamBrand)) {
needPreAggregation = false;
}
... ...
... ... @@ -47,8 +47,8 @@ import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.service.aggregations.impls.AggregationFactoryService;
import com.yoho.search.service.cache.SearchCacheMatchLogger;
import com.yoho.search.service.cache.SearchCacheFactory;
import com.yoho.search.service.cache.SearchCacheMatchLogger;
import com.yoho.search.service.cache.model.SearchCache;
import com.yoho.search.service.service.AggregationService;
import com.yoho.search.service.service.SearchCacheService;
... ... @@ -60,6 +60,7 @@ import com.yoho.search.service.service.helper.SearchParamHelper;
import com.yoho.search.service.service.helper.SearchSortHelper;
import com.yoho.search.service.servicenew.IBrandService;
import com.yoho.search.service.utils.SearchApiResultUtils;
import com.yoho.search.service.utils.SearchRequestParams;
import com.yoho.search.service.vo.SearchApiResult;
@Service
... ... @@ -116,7 +117,7 @@ public class BrandServiceImpl implements IBrandService, ApplicationEventPublishe
public SearchApiResult aggBrand(Map<String, String> paramMap, BoolQueryBuilder mustFilter) {
try {
// 1、构造带filter和query的SearchParam
boolean needPreAggregation = "Y".equals(paramMap.getOrDefault("aggWithParamBrand", "N")) ? false : true;
boolean needPreAggregation = "Y".equals(paramMap.getOrDefault(SearchRequestParams.PARAM_SEARCH_AGG_WITH_PARAM_BRAND, "N")) ? false : true;
SearchParam searchParam = searchParamHelper.buildSearchParam(paramMap, false, mustFilter, needPreAggregation ? "brand" : null);
// 2、构造aggrations
... ... @@ -290,7 +291,7 @@ public class BrandServiceImpl implements IBrandService, ApplicationEventPublishe
// 4、构建searchParam
SearchParam searchParam = searchParamHelper.buildWithPersional(paramMap, topHitCount > 0 ? true : false);
IAggregation groupBrandAgg = aggregationFactoryService.getGroupBrandAggregation(paramMap, topHitOrder, topHitCount);
IAggregation groupBrandAgg = aggregationFactoryService.getGroupBrandAggregation(topHitOrder, topHitCount);
searchParam.setAggregationBuilders(Arrays.asList(groupBrandAgg.getBuilder()));
searchParam.setSize(0);
searchParam.setOffset(topHitCount * 2);// justForCache
... ...
... ... @@ -101,13 +101,12 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
if (topHitCount > 0 && searchCommonHelper.isNeedPersonalSearch(paramMap)) {
topHitOrder = "_score:desc";
}
IAggregation groupShopAgg = aggregationFactoryService.getGroupShopAggregation(paramMap, topHitOrder, topHitCount);
IAggregation groupShopAgg = aggregationFactoryService.getGroupShopAggregation(topHitOrder, topHitCount);
// 4、构建searchParam
SearchParam searchParam = searchParamHelper.buildWithPersional(paramMap, topHitCount > 0 ? true : false);
searchParam.setAggregationBuilders(Arrays.asList(groupShopAgg.getBuilder()));
searchParam.setSize(0);
searchParam.setOffset(topHitCount * 2);// justForCache
searchParam.setSize(0);
// 5、从缓存中获取
final String productIndexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
... ...
... ... @@ -22,12 +22,11 @@ public abstract class AbstractSceneService {
paramMap.put(SearchRequestParams.PARAM_SEARCH_SHOWSOLDOUT, "1");// 显示延期显示的商品
paramMap.put(SearchRequestParams.PARAM_SEARCH_ISOUTLETS, "2");// 非奥莱
paramMap.put(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE_NOT, "2");// 非赠品
paramMap.put(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE_NOT, "2");// 非赠品
paramMap.put("aggWithParamBrand", "Y");// 聚合时使用参数中自带的参数
paramMap.put("needSmallSort", "1");// 品类聚合时带上小分类
paramMap.put(SearchRequestParams.PARAM_SEARCH_NEEDSMALLSORT, "1");// 品类聚合时带上小分类
paramMap.put(SearchRequestParams.PARAM_SEARCH_AGG_WITH_PARAM_BRAND, "Y");// 聚合时使用参数中自带的参数
// paramMap.put("sale", "Y");// 没用的参数
}
protected int getPage(Map<String, String> paramMap) {
int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));
return page;
... ...
... ... @@ -101,8 +101,8 @@ public class SceneProductListService extends BaseService {
if (page < 1 || pageSize < 0) {
throw new IllegalArgumentException("分页参数不合法");
}
if (pageSize > 500) {
pageSize = 500;
if (pageSize > 100) {
pageSize = 100;
}
// 2)构建基本查询参数
SearchParam searchParam = searchParamHelper.buildWithPersional(paramMap, true);
... ...
... ... @@ -14,6 +14,8 @@ public class SearchRequestParams {
public static final String PARAM_SEARCH_MIDDLESORT = "misort"; // 查询中类
public static final String PARAM_SEARCH_SMALLSORT = "sort"; // 查询小类
public static final String PARAM_SEARCH_COMMONSORT = "common_sort";// 不区分大中小分类的品类id
public static final String PARAM_SEARCH_NEEDSMALLSORT = "needSmallSort";// 聚合时使用小分类参数
public static final String PARAM_SEARCH_AGG_WITH_PARAM_BRAND = "aggWithParamBrand";// 聚合时使用参数中的品牌id
public static final String PARAM_SEARCH_AGELEVEL = "ageLevel"; // 查询年龄段
public static final String PARAM_SEARCH_APPTYPE = "app_type"; // APP类型
... ... @@ -54,7 +56,7 @@ public class SearchRequestParams {
public static final String PARAM_SEARCH_SELLCHANNELS = "sell_channels"; // ◆销售平台(网站、APP、现场)
public static final String PARAM_SEARCH_FOLDERID = "folder_id"; //
public static final String PARAM_SEARCH_SERIESID = "series_id"; //
public static final String PARAM_SEARCH_COUPONLIMITSTATUS = "couponLimitStatus"; //
public static final String PARAM_SEARCH_COUPONLIMITSTATUS = "couponLimitStatus"; //
public static final String PARAM_SEARCH_ATTRIBUTE_NOT = "attribute_not"; // ◆商品属性
public static final String PARAM_SEARCH_STATUS = "status"; // 查询是否上架
... ... @@ -62,7 +64,6 @@ public class SearchRequestParams {
public static final String PARAM_SEARCH_ORDER = "order";// 排序值
public static final String PARAM_SEARCH_SHOP = "shop";// 店铺id
public static final String PARAM_SEARCH_DAY = "day"; // 上架日期
public static final String PARAM_SEARCH_BREAKING = "breaking"; // 是否断码
... ... @@ -70,7 +71,7 @@ public class SearchRequestParams {
public static final String PARAM_SEARCH_CONTAIN_GLOBAL = "contain_global"; // 是否包含全球购
public static final String PARAM_SEARCH_IS_GLOBAL = "is_global"; // 是否只看全球购【y/n】
public static final String PARAM_SEARCH_CONTAIN_SECKILL = "contain_seckill"; // 是否包含秒杀[y]
public static final String PARAM_SEARCH_CONTAIN_FOBBIDEN = "contain_fobbiden"; // 是否包含秒杀[y]
public static final String PARAM_SEARCH_CONTAIN_FOBBIDEN = "contain_fobbiden"; // 是否包含秒杀[y]
public static final String PARAM_SEARCH_SHOWSOLDOUT = "showSoldOut"; // 是否显示售罄商品[1]
public static final String PARAM_SEARCH_FIRST_PRODUCRSKN = "firstProductSkn";// 展示在前面的skns
... ... @@ -81,18 +82,18 @@ public class SearchRequestParams {
public static final String PARAM_SEARCH_NEED_SUGGESTION = "needSuggestion"; // 是否返回分词推荐[Y/N]
public static final int RESULT_SIZE_SUGGEST = 5;// suggest返回个数
public static final String PARAM_SEARCH_PRICE_UPDATE_TIME = "priceUpdateTime"; // 价格更新时间
public static final String PARAM_SEARCH_LAST_REDUCE_PRICE_TIME = "lastReducePriceTime"; // 降价时间
public static final String PARAM_SEARCH_IS_FOR_MARKET_PROMOTION = "isForMarketPromotion"; // 市场推广参数
public static final String PARAM_SEARCH_PRICE_UPDATE_TIME = "priceUpdateTime"; // 价格更新时间
public static final String PARAM_SEARCH_LAST_REDUCE_PRICE_TIME = "lastReducePriceTime"; // 降价时间
public static final String PARAM_SEARCH_IS_FOR_MARKET_PROMOTION = "isForMarketPromotion"; // 市场推广参数
// 活动模板相关过滤条件
public static final String PARAM_SEARCH_ACT_TEMP = "act_temp"; // 模板id
public static final String PARAM_SEARCH_ACT_REC = "act_rec"; // 是否推荐
public static final String PARAM_SEARCH_ACT_STATUS = "act_status"; // 状态
//店铺显示状态
public static final String PARAM_SEARCH_STORESHOWSTATUS = "storeShowStatus";
// 店铺显示状态
public static final String PARAM_SEARCH_STORESHOWSTATUS = "storeShowStatus";
// helper index param
public static final String HELPER_PARAM_FIRSTCATEGORYID = "firstCategoryId";
... ...