Authored by 胡古飞

Merge branch '0110' into test

... ... @@ -40,7 +40,7 @@ public class PromotionController {
Map<String, String> paramMap = this.genOtherParamMap(param);
return promotionService.list(promotionConditions, paramMap);
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(e.getMessage(),e);
return new SearchApiResult().setCode(400).setMessage("参数解析错误");
}
}
... ... @@ -53,7 +53,7 @@ public class PromotionController {
Map<String, String> paramMap = this.genOtherParamMap(param);
return promotionService.selectionsForApp(promotionConditions, paramMap);
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(e.getMessage(),e);
return new SearchApiResult().setCode(400).setMessage("参数解析错误");
}
}
... ... @@ -72,7 +72,7 @@ public class PromotionController {
Map<String, String> paramMap = this.genOtherParamMap(param);
return promotionService.selectionsForApp(promotionConditions, paramMap);
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(e.getMessage(),e);
return new SearchApiResult().setCode(400).setMessage("参数解析错误");
}
}
... ... @@ -91,7 +91,7 @@ public class PromotionController {
Map<String, String> paramMap = this.genOtherParamMap(param);
return promotionService.selectionsForPc(promotionConditions, paramMap);
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(e.getMessage(),e);
return new SearchApiResult().setCode(400).setMessage("参数解析错误");
}
}
... ... @@ -110,7 +110,7 @@ public class PromotionController {
Map<String, String> paramMap = this.genOtherParamMap(param);
return promotionService.aggPromotionBrands(promotionConditions, paramMap);
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(e.getMessage(),e);
return new SearchApiResult().setCode(400).setMessage("参数解析错误");
}
}
... ...
... ... @@ -43,7 +43,7 @@ public class SearchServiceHelper {
private DynamicSearchRuleHelper dynamicSearchRuleHelper;
@Autowired
private FunctionScoreSearchHelper functionScoreSearchHelper;
/**
* 构造关键字查询的query
*
... ... @@ -97,7 +97,7 @@ public class SearchServiceHelper {
return queryBuilder;
}
/**
* 构造关键字查询的query的时候operator默认为or,minimum匹配度是50%
*
... ... @@ -145,20 +145,25 @@ public class SearchServiceHelper {
QueryBuilder queryBuilder = this.constructQueryBuilder(paramMap);
queryBuilder = functionScoreSearchHelper.buildFunctionScoreQueryBuild(queryBuilder, paramMap);
return queryBuilder;
// queryBuilder = this.buildPersonalSearch(queryBuilder, paramMap);
// queryBuilder = this.buildFunctionScoreQueryBuild(queryBuilder, paramMap);
// return queryBuilder;
// String dynamicRuleValue = dynamicSearchRuleHelper.getDynamicRuleValue(paramMap);
// if (StringUtils.isEmpty(dynamicRuleValue) || "-1".equals(dynamicRuleValue)) {
// queryBuilder = this.buildGlobalSearch(queryBuilder, paramMap);
// queryBuilder = this.buildDeScoreBrandSearch(queryBuilder, paramMap);
// } else {
// queryBuilder = dynamicSearchRuleHelper.buildDynamicSerach(queryBuilder, paramMap, dynamicRuleValue);
// }
// return queryBuilder;
// queryBuilder = this.buildPersonalSearch(queryBuilder, paramMap);
// queryBuilder = this.buildFunctionScoreQueryBuild(queryBuilder,
// paramMap);
// return queryBuilder;
// String dynamicRuleValue =
// dynamicSearchRuleHelper.getDynamicRuleValue(paramMap);
// if (StringUtils.isEmpty(dynamicRuleValue) ||
// "-1".equals(dynamicRuleValue)) {
// queryBuilder = this.buildGlobalSearch(queryBuilder, paramMap);
// queryBuilder = this.buildDeScoreBrandSearch(queryBuilder, paramMap);
// } else {
// queryBuilder =
// dynamicSearchRuleHelper.buildDynamicSerach(queryBuilder, paramMap,
// dynamicRuleValue);
// }
// return queryBuilder;
}
public QueryBuilder constructOrQueryBuilderForProductList(Map<String, String> paramMap) {
QueryBuilder queryBuilder = this.constructOrQueryBuilder(paramMap);
queryBuilder = functionScoreSearchHelper.buildFunctionScoreQueryBuild(queryBuilder, paramMap);
... ... @@ -675,10 +680,7 @@ public class SearchServiceHelper {
productMap.put("sales_num", map.get("salesNum"));
productMap.put("status", map.get("status"));
productMap.put("is_promotion", map.get("ispromotion"));
productMap.put("is_promotion", map.get("ispromotion"));
productMap.put("tbl_country_id", map.get("tblCountryId"));
productMap.put("tbl_country_name", map.get("tblCountryName"));
productMap.put("is_promotion", map.get("ispromotion"));
String yohoodIdFromMap = (String) map.get("yohoodId");
if (yohoodIdFromMap != null && yohoodIdFromMap.length() > 0) {
productMap.put("yohood_id", yohoodIdFromMap);
... ... @@ -695,13 +697,22 @@ public class SearchServiceHelper {
productMap.put("student_price", map.get("studentPrice"));
}
productMap.put("country_id", map.get("countryId"));
// 是否是全球购商品
productMap.put("is_global", map.get("isGlobal") == null ? "N" : map.get("isGlobal"));
// 是否学生返币
productMap.put("is_student_rebate", map.get("isstudentrebate") == null ? "N" : map.get("isstudentrebate"));
// 年龄层,逗号隔开的字符串
productMap.put("age_level", map.get("ageLevel") == null ? "" : map.get("ageLevel"));
// 是否是全球购商品
productMap.put("is_global", map.get("isGlobal") == null ? "N" : map.get("isGlobal"));
Integer tbl_country_id = 0;
try {
tbl_country_id = (Integer) map.get("tblCountryId");
} catch (Exception e) {
}
productMap.put("tbl_country_id", tbl_country_id);
productMap.put("tbl_country_name", map.get("tblCountryName"));
String tbl_plane = (tbl_country_id !=null && tbl_country_id!=86) ? "Y" : "N";
productMap.put("tbl_plane", tbl_plane);
return productMap;
}
}
... ...
... ... @@ -141,7 +141,7 @@ public class SearchSortHelper {
// 都要添加次要排序条件
private void addDeafultSortBuildSorts(List<SortBuilder> sortBuilders,List<String> filteredFieldNames) {
this.addSortBuildSorts(sortBuilders, filteredFieldNames, "shelveTime", SortOrder.DESC);
this.addSortBuildSorts(sortBuilders, filteredFieldNames, "firstShelveTime", SortOrder.DESC);
this.addSortBuildSorts(sortBuilders, filteredFieldNames, "id", SortOrder.DESC);
}
... ...
... ... @@ -29,6 +29,7 @@ import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -120,11 +121,10 @@ public class AggProductListServiceImpl implements IAggProductListService,Applica
SearchApiResult searchApiResult = new SearchApiResult().setMessage("agg productList list");
// 6、先从缓存中获取,如果能取到,则直接返回
JSONArray jsonArray = searchCacheService.getJSONArrayFromCache(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
if (jsonArray != null) {
return searchApiResult.setData(jsonArray);
JSONObject jsonObject = searchCacheService.getJSONObjectFromCache(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
if (jsonObject != null) {
return searchApiResult.setData(jsonObject);
}
// 7、执行搜索,并构造返回结果
final String indexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
SearchResult searchResult = searchCommonService.doSearch(indexName, searchParam);
... ... @@ -136,12 +136,18 @@ public class AggProductListServiceImpl implements IAggProductListService,Applica
return searchApiResult.setData("");
}
JSONArray productList = this.getProductList(((MultiBucketsAggregation) aggMaps.get(firstAggName)));
searchCacheService.addJSONArrayToCache(indexName, searchParam, productList);
return searchApiResult.setData(productList);
jsonObject = new JSONObject();
jsonObject.put("total", productList==null ?0:productList.size());
jsonObject.put("page", 1);
jsonObject.put("page_size", viewNum);
jsonObject.put("page_total", 1);
jsonObject.put("product_list", productList);
searchCacheService.addJSONObjectToCache(indexName, searchParam, jsonObject);
return searchApiResult.setData(jsonObject);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.SEARCHCONTROLLER_NEW_SHELVE.getEventName(), EventReportEnum.SEARCHCONTROLLER_NEW_SHELVE.getFunctionName(),
EventReportEnum.SEARCHCONTROLLER_NEW_SHELVE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
return SearchApiResultUtils.errorSearchApiResult("searchNewestProductWithDiffBrand", paramMap, e);
publisher.publishEvent(new SearchEvent(EventReportEnum.SEARCHCONTROLLER_AGG_PRODUCTLIST.getEventName(), EventReportEnum.SEARCHCONTROLLER_AGG_PRODUCTLIST.getFunctionName(),
EventReportEnum.SEARCHCONTROLLER_AGG_PRODUCTLIST.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
return SearchApiResultUtils.errorSearchApiResult("aggProductList", paramMap, e);
}
}
... ...
... ... @@ -18,6 +18,7 @@ import com.yoho.search.service.utils.SearchApiResultUtils;
import com.yoho.search.service.utils.SearchRequestParams;
import com.yoho.search.service.vo.SearchApiResult;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.*;
import org.elasticsearch.search.SearchHit;
... ... @@ -222,6 +223,9 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
if (keyword.contains("%")) {
keyword.replace("%", "percent");// 特殊处理
}
if (keyword.equals("耐克")) {
keyword = "nike";
}
// 编码转换
String is_encode = paramMap.get("is_encode");
if (StringUtils.isNotBlank(is_encode) && is_encode.equals("1")) {
... ... @@ -238,19 +242,19 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
returnMap.put("brand", null);
returnMap.put("tblBrand", null);
//tbl判断
if (paramMap.containsKey("contain_global") && "Y".equals(paramMap.get("contain_global"))) {
searchApiResult = searchTbl(paramMap, keyword);
if (searchApiResult.getData() != null) {
Map<String, Object> shopInfoMap = (Map<String, Object>) searchApiResult.getData();
JSONObject shopDataMap = new JSONObject();
Integer shopIdNumber = Integer.valueOf(shopInfoMap.get("shopsId").toString());
shopDataMap.put("brand_id", shopIdNumber * (-1));
shopDataMap.put("brand_name", shopInfoMap.get("shopName") == null ? "" : shopInfoMap.get("shopName"));
shopDataMap.put("brand_logo", shopInfoMap.get("shopLogo") == null ? "" : shopInfoMap.get("shopLogo"));
returnMap.put("tblBrand", shopDataMap);
return searchApiResult.setData(returnMap);
}
//if (paramMap.containsKey("contain_global") && "Y".equals(paramMap.get("contain_global"))) {
searchApiResult = searchTbl(paramMap, keyword);
if (searchApiResult.getData() != null) {
Map<String, Object> shopInfoMap = (Map<String, Object>) searchApiResult.getData();
JSONObject shopDataMap = new JSONObject();
Integer shopIdNumber = Integer.valueOf(shopInfoMap.get("shopsId").toString());
shopDataMap.put("brand_id", shopIdNumber * (-1));
shopDataMap.put("brand_name", shopInfoMap.get("shopName") == null ? "" : shopInfoMap.get("shopName"));
shopDataMap.put("brand_logo", shopInfoMap.get("shopLogo") == null ? "" : shopInfoMap.get("shopLogo"));
returnMap.put("tblBrand", shopDataMap);
return searchApiResult.setData(returnMap);
}
//}
// 2、配置keyword的查询字段以及权重设置
MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(keyword);
... ... @@ -389,7 +393,13 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
dataMapMap.put(lt.getKeyAsString(), map);
//处理品牌信息
Map<String, Object> shopsInfo = shopInfoMap.get(lt.getKeyAsString());
map.put("info", shopsInfo);
Map<String, Object> shopDataMap = new HashedMap();
shopDataMap.put("shop_id", shopsInfo.get("shopsId"));
shopDataMap.put("shop_name", shopsInfo.get("shopName") == null ? "" : shopsInfo.get("shopName"));
shopDataMap.put("shop_logo", shopsInfo.get("shopLogo") == null ? "" : shopsInfo.get("shopLogo"));
shopDataMap.put("shop_domain", shopsInfo.get("shopDomain") == null ? "" : shopsInfo.get("shopDomain"));
shopDataMap.put("shop_type", shopsInfo.get("shopsType") == null ? "" : shopsInfo.get("shopsType"));
map.put("info", shopDataMap);
dataMapMap.put(lt.getKeyAsString(), map);
}
try {
... ... @@ -533,9 +543,9 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
int[] shopsIds = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOP), ",");
boolFilter.must(QueryBuilders.termsQuery("shopsId", shopsIds));
}
if (!paramMap.containsKey("contain_global") && !"Y".equals(paramMap.get("contain_global"))) {
boolFilter = boolFilter.must(QueryBuilders.termQuery("isGlobal", "N"));
}
// if (!paramMap.containsKey("contain_global") && !"Y".equals(paramMap.get("contain_global"))) {
// boolFilter = boolFilter.must(QueryBuilders.termQuery("isGlobal", "N"));
// }
boolFilter = BoolQueryTermQuery(paramMap, boolFilter, SearchRequestParams.SHOPS_PARAM_BLKSTATUS);
boolFilter = BoolQueryTermQuery(paramMap, boolFilter, SearchRequestParams.SHOPS_PARAM_CHECKSTATUS);
boolFilter = BoolQueryTermQuery(paramMap, boolFilter, SearchRequestParams.SHOPS_PARAM_EXAMINESTATUS);
... ...