Authored by wangnan

shops支持搜索全球购店铺 fix

package com.yoho.search.service.service.helper;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.MultiMatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.DateUtil;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -32,6 +11,17 @@ import com.yoho.search.service.service.SearchCommonService;
import com.yoho.search.service.service.SearchDynamicConfigService;
import com.yoho.search.service.service.SearchKeyWordService;
import com.yoho.search.service.utils.SearchRequestParams;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.*;
@Service
public class SearchServiceHelper {
... ... @@ -679,6 +669,9 @@ 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"));
String yohoodIdFromMap = (String) map.get("yohoodId");
if (yohoodIdFromMap != null && yohoodIdFromMap.length() > 0) {
... ...
... ... @@ -52,6 +52,7 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
ApplicationEventPublisher publisher;
@Autowired
private SearchCommonService searchCommonService;
@Autowired
... ... @@ -225,24 +226,26 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
}
}
//tbl判断
SearchApiResult searchApiResult = searchTbl(paramMap,keyword);
SearchApiResult searchApiResult = new SearchApiResult();
JSONObject returnMap = new JSONObject();
returnMap.put("shop", null);
returnMap.put("brand", null);
returnMap.put("tblBrand", null);
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);
//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);
}
}
// 2、配置keyword的查询字段以及权重设置
MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(keyword);
queryBuilder.operator(MatchQueryBuilder.Operator.OR);
... ... @@ -315,6 +318,7 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
/**
* shopsNew中搜索是否有匹配的全球购店铺,如果有直接返回。
*
* @param paramMap
* @param keyword
* @return
... ... @@ -468,6 +472,9 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
*/
private BoolQueryBuilder constructShopsFilterBuilder(Map<String, String> paramMap) throws Exception {
BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
if (!paramMap.containsKey("contain_global") && !"Y".equals(paramMap.get("contain_global"))) {
boolFilter = boolFilter.must(QueryBuilders.termQuery("contain_global", "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);
... ...
... ... @@ -75,6 +75,7 @@ public class SearchRequestParams {
public static final String SHOPS_PARAM_OPERATIONSTATUS = "operationStatus";
public static final String SHOPS_PARAM_SHOPSTYPE = "shopsType";
public static final String SHOPS_PARAM_STATUS = "status";
public static final String SHOPS_PARAM_ISGLOBAL = "isGlobal";
... ...