Authored by 胡古飞

ufo列表支持showChannel参数

... ... @@ -7,18 +7,19 @@ public class UfoSearchRequestParams {
public static final String UFO_PARAM_SEARCH_VIEWNUM = "viewNum"; // 数量
//ufo
public static final String UFOPRODUCTINDEX_SEARCH_QUERY = "query";
public static final String UFOPRODUCTINDEX_PARAM_ID = "id";
public static final String UFOPRODUCTINDEX_PARAM_NOT_ID = "not_id";
public static final String UFOPRODUCTINDEX_PARAM_MAXSORT = "maxSort";
public static final String UFOPRODUCTINDEX_PARAM_MIDSORT = "midSort";
public static final String UFOPRODUCTINDEX_PARAM_GENDER = "gender";
public static final String UFOPRODUCTINDEX_PARAM_BRAND = "brand";
public static final String UFOPRODUCTINDEX_PARAM_NOT_BRAND = "not_brand";
public static final String UFOPRODUCTINDEX_PARAM_SERIES = "series";
public static final String UFOPRODUCTINDEX_PARAM_SIZE = "size";
public static final String UFOPRODUCTINDEX_PARAM_COLOR = "color";
public static final String UFOPRODUCTINDEX_PARAM_POOL = "pool";
public static final String UFO_PARAM_SEARCH_QUERY = "query";
public static final String UFO_PARAM_ID = "id";
public static final String UFO_PARAM_NOT_ID = "not_id";
public static final String UFO_PARAM_MAXSORT = "maxSort";
public static final String UFO_PARAM_MIDSORT = "midSort";
public static final String UFO_PARAM_GENDER = "gender";
public static final String UFO_PARAM_BRAND = "brand";
public static final String UFO_PARAM_NOT_BRAND = "not_brand";
public static final String UFO_PARAM_SERIES = "series";
public static final String UFO_PARAM_SIZE = "size";
public static final String UFO_PARAM_COLOR = "color";
public static final String UFO_PARAM_POOL = "pool";
public static final String UFO_PARAM_SHOW_CHANNEL = "showChannel";
// ufo发售日历 商品类型
public static final String UFO_PARAM_SEARCH_SALE_CALENDAR_PRODUCT_TYPE = "product_type";
... ... @@ -31,4 +32,8 @@ public class UfoSearchRequestParams {
// ufo 融入有货
public static final String UFO_PARAM_SEARCH_CONTAIN_YOHO = "contain_yoho";
//二手列表
public static final String UFO_PARAM_MAXSTORAGEPRICE_ID = "maxStoragePriceId";
public static final String UFO_PARAM_PRE_SALE_FLAG = "preSaleFlag";
}
... ...
package com.yoho.search.restapi.ufo;
import com.yoho.search.common.UfoSearchRequestParams;
import com.yoho.search.common.utils.HttpServletRequestUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.service.scene.ufo.UfoMaxStoragePriceIdService;
... ... @@ -24,7 +25,8 @@ public class UfoSecondhandController {
public SearchApiResult secondHandSkupList(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
int maxStoragePriceId = ufoMaxStoragePriceIdService.queryUfoMaxStoragePriceId();
paramMap.put("maxStoragePriceId",maxStoragePriceId+"");
paramMap.put(UfoSearchRequestParams.UFO_PARAM_MAXSTORAGEPRICE_ID, maxStoragePriceId + "");
return ufoSecondhandSkupService.secondHandSkupList(paramMap);
}
}
... ...
... ... @@ -63,17 +63,18 @@ public class UfoSearchQueryHelper extends BaseService {
public BoolQueryBuilder constructFilterBuilder(Map<String, String> paramMap) throws Exception {
BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
//参数过滤
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_ID, UfoProductIndexEsField.id);
this.addMustNotIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_NOT_ID, UfoProductIndexEsField.id);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_MAXSORT, UfoProductIndexEsField.maxSortId);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_MIDSORT, UfoProductIndexEsField.midSortId);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_GENDER, UfoProductIndexEsField.gender);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_BRAND, UfoProductIndexEsField.brandId);
this.addMustNotIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_NOT_BRAND, UfoProductIndexEsField.brandId);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_SERIES, UfoProductIndexEsField.seriesId);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_SIZE, UfoProductIndexEsField.sizeIds);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_COLOR, UfoProductIndexEsField.colorIds);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_POOL, UfoProductIndexEsField.poolIds);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_ID, UfoProductIndexEsField.id);
this.addMustNotIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_NOT_ID, UfoProductIndexEsField.id);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_MAXSORT, UfoProductIndexEsField.maxSortId);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_MIDSORT, UfoProductIndexEsField.midSortId);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_GENDER, UfoProductIndexEsField.gender);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_BRAND, UfoProductIndexEsField.brandId);
this.addMustNotIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_NOT_BRAND, UfoProductIndexEsField.brandId);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_SERIES, UfoProductIndexEsField.seriesId);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_SIZE, UfoProductIndexEsField.sizeIds);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_COLOR, UfoProductIndexEsField.colorIds);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_POOL, UfoProductIndexEsField.poolIds);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_SHOW_CHANNEL, UfoProductIndexEsField.showChannel);
//是否包含有货
if (!this.containYoho(paramMap)) {
... ... @@ -110,7 +111,7 @@ public class UfoSearchQueryHelper extends BaseService {
public BoolQueryBuilder constructFilterBuilderIdFilter(Map<String, String> paramMap) throws Exception {
BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_ID, UfoProductIndexEsField.id);
this.addMustIntTermsQuery(boolFilter, paramMap, UfoSearchRequestParams.UFO_PARAM_ID, UfoProductIndexEsField.id);
return boolFilter;
}
... ... @@ -130,25 +131,25 @@ public class UfoSearchQueryHelper extends BaseService {
boolFilter.mustNot(QueryBuilders.termsQuery(esField, values));
}
public QueryBuilder constructQueryBuilder(Map<String, String> paramMap) {
// 0、处理查询关键字
String query = SearchKeyWordUtils.getUfoParamKeyword(paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_SEARCH_QUERY);
// 1、处理查询关键字
String query = SearchKeyWordUtils.getUfoParamKeyword(paramMap, UfoSearchRequestParams.UFO_PARAM_SEARCH_QUERY);
if (StringUtils.isBlank(query)) {
return QueryBuilders.matchAllQuery();
}
paramMap.put(UfoSearchRequestParams.UFOPRODUCTINDEX_SEARCH_QUERY, query);
paramMap.put(UfoSearchRequestParams.UFO_PARAM_SEARCH_QUERY, query);
// 1、处理查询中包含性别的情况
// 2、处理查询中包含性别的情况
searchCommonHelper.dealKeywordOfGender(query, paramMap);
// 2、构建多字段匹配
// 3、构建多字段匹配
MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(query);
MultiMatchQueryBuilder.Type multiMatchQueryBuilderType = searchCommonHelper.getMultiMatchQueryBuilderType();
if (multiMatchQueryBuilderType != null) {
queryBuilder.type(multiMatchQueryBuilderType);
}
// 3.如果查询的是skn或skuIds
// 4.如果查询的是skn或skuIds
if (searchCommonHelper.isQueryUfoProductId(query)) {
queryBuilder.field(UfoProductIndexEsField.idString);
queryBuilder.field(UfoProductIndexEsField.productCode);
... ... @@ -156,14 +157,16 @@ public class UfoSearchQueryHelper extends BaseService {
queryBuilder.minimumShouldMatch("1");
return queryBuilder;
}
// 4.设置查询字段和比重
// 5.设置查询字段和比重
List<SearchField> searchFields = SearchFieldUtils.getUfoFuzzySearchFields();
if (CollectionUtils.isNotEmpty(searchFields)) {
for (SearchField searchField : searchFields) {
queryBuilder.field(searchField.getEsField(), searchField.getBoost());
}
}
// 5.设置
// 6.设置
if ("or".equalsIgnoreCase(configurer.getSearchOperator())) {
queryBuilder.operator(Operator.OR);
queryBuilder.minimumShouldMatch(configurer.getUfoSearchMinimumShouldMatch());
... ...
... ... @@ -74,7 +74,7 @@ public class UfoProductIndexBaseService {
return productMap;
}
public Map<Integer,Map<String,Object>> queryMapByProductIds(final Collection<?> ufoProductIds) {
public Map<Integer,Map<String,Object>> queryUfoProductMapByProductIds(final Collection<?> ufoProductIds) {
List<Map<String, Object>> resultList = this.queryListByProductIds(ufoProductIds);
return resultList.stream().collect(Collectors.toMap(a->MapUtils.getIntValue(a,"id",0),p->p));
}
... ...
... ... @@ -49,7 +49,7 @@ public class UfoFavoriteService {
public SearchApiResult productList(Map<String, String> paramMap) {
try {
// 1、参数校验
if (StringUtils.isBlank(paramMap.get(UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_ID))) {
if (StringUtils.isBlank(paramMap.get(UfoSearchRequestParams.UFO_PARAM_ID))) {
return new SearchApiResult().setCode(400).setMessage("id参数必传");
}
int pageSize = StringUtils.isBlank(paramMap.get("viewNum")) ? 10 : Integer.parseInt(paramMap.get("viewNum"));
... ... @@ -82,7 +82,7 @@ public class UfoFavoriteService {
dataMap.put("page_total", searchResult.getTotalPage());
Map<String, Map<String, Object>> productReturnInfoMap = returnInfoList.stream().collect(Collectors.toMap(p -> p.get("id").toString(), p -> p));
List<Map<String, Object>> productReturnInfoListSorted = new ArrayList<>(productReturnInfoMap.size());
List<String> idList = Arrays.asList(paramMap.get(UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_ID).split(","));
List<String> idList = Arrays.asList(paramMap.get(UfoSearchRequestParams.UFO_PARAM_ID).split(","));
for (String id : idList) {
Map<String, Object> sknInfo = productReturnInfoMap.get(id);
if (sknInfo != null) {
... ...
... ... @@ -138,7 +138,7 @@ public class UfoFuzzySceneService {
public SearchParam buildSearchParamForProductCodeSearch(Map<String, String> paramMap, int pageSize, int page) throws Exception {
SearchParam searchParam = new SearchParam();
// QUERY
String query = SearchKeyWordUtils.getUfoParamKeyword(paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_SEARCH_QUERY);
String query = SearchKeyWordUtils.getUfoParamKeyword(paramMap, UfoSearchRequestParams.UFO_PARAM_SEARCH_QUERY);
if (StringUtils.isBlank(query)) {
searchParam.setQuery(QueryBuilders.matchAllQuery());
} else {
... ...
... ... @@ -53,7 +53,7 @@ public class UfoPoolSceneService {
public SearchApiResult productList(Map<String, String> paramMap) {
try {
// 1、参数校验
if (!paramMap.containsKey(UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_POOL)) {
if (!paramMap.containsKey(UfoSearchRequestParams.UFO_PARAM_POOL)) {
return new SearchApiResult().setCode(400).setMessage("缺少必传pool参数");
}
int page = MapUtils.getIntValue(paramMap, "page", 1);
... ... @@ -137,7 +137,7 @@ public class UfoPoolSceneService {
private int getPoolOrderBy(Map<String, Object> map, Map<String, String> paramMap) {
try {
String inputPoolId = MapUtils.getString(paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_PARAM_POOL, "");
String inputPoolId = MapUtils.getString(paramMap, UfoSearchRequestParams.UFO_PARAM_POOL, "");
if (StringUtils.isBlank(inputPoolId)) {
return 0;
}
... ...
... ... @@ -91,9 +91,10 @@ public class UfoProductListService {
// QUERY
QueryBuilder queryBuilder = ufoSearchQueryHelper.constructQueryBuilder(paramMap);
searchParam.setQuery(queryBuilder);
//Filter
// Filter
BoolQueryBuilder boolFilter = ufoSearchQueryHelper.constructFilterBuilder(paramMap);
searchParam.setFiter(boolFilter);
// 聚合和分页
searchParam.setAggregationBuilders(null);
searchParam.setSize(pageSize);
searchParam.setOffset((page - 1) * pageSize);
... ... @@ -181,8 +182,8 @@ public class UfoProductListService {
this.addReturnInfoList(paramMap, idList, returnInfoList, RECOMMEND_BY_SERIES_BRAND_LIMIT);
}
// 添加自定义标签
customizeTagBaseService.fillCustomizeTag(returnInfoList,false);
customizeTagBaseService.fillCustomizeTag(returnInfoList, false);
dataMap.put("total", returnInfoList.size());
return searchApiResult;
} catch (Exception e) {
... ...
... ... @@ -52,23 +52,18 @@ public class UfoSecondhandSkupService {
if (page < 1 || pageSize < 0 || page * pageSize > 100000) {
return new SearchApiResult().setCode(400).setMessage("分页参数不合法");
}
// 2、构造SearchParam
SearchParam searchParam = new SearchParam();
BoolQueryBuilder boolFilter = this.builderFilter(paramMap);
searchParam.setFiter(boolFilter);
searchParam.setQuery(QueryBuilders.matchAllQuery());
// 3、构建分页参数
searchParam.setSize(pageSize);
searchParam.setOffset((page - 1) * pageSize);
// 4、设置排序字段
searchParam.setSortBuilders(Arrays.asList(SortBuilders.fieldSort("id").order(SortOrder.DESC)));
// 5、执行搜索
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_UFO_STORAGE_PRICE, searchParam);
// 6、构造搜索结果
List<Map<String, Object>> skupResultList = new ArrayList<>();
List<Integer> ufoProductIds = new ArrayList<>();
... ... @@ -76,27 +71,26 @@ public class UfoSecondhandSkupService {
skupResultList.add(ufoStoragePriceIndexBaseService.buildStoragePriceMap(skupEsSource));
ufoProductIds.add(MapUtils.getIntValue(skupEsSource, "productId", 0));
}
// 7、根据productIds查询商品信息
Map<Integer, Map<String, Object>> results = ufoProductIndexBaseService.queryMapByProductIds(ufoProductIds);
Map<Integer, Map<String, Object>> ufoProductMap = ufoProductIndexBaseService.queryUfoProductMapByProductIds(ufoProductIds);
skupResultList.stream().forEach(skupResult -> {
int productId = MapUtils.getIntValue(skupResult, "product_id", 0);
Map<String, Object> productInfo = results.get(productId);
if (productInfo == null) {
Map<String, Object> ufoProductInfo = ufoProductMap.get(productId);
if (ufoProductInfo == null) {
skupResult.put("product_name", "");
skupResult.put("save_price", null);
return;
}
// 商品名称处理
skupResult.put("product_name", MapUtils.getString(productInfo, "product_name", ""));
// 图片处理,二手图片不存在用默认的商品图片代替
String product_default_images = MapUtils.getString(productInfo, "default_images", "");
// 1) 商品名称处理
skupResult.put("product_name", MapUtils.getString(ufoProductInfo, "product_name", ""));
// 2) 图片处理,二手图片不存在用默认的商品图片代替
String product_default_images = MapUtils.getString(ufoProductInfo, "default_images", "");
if (StringUtils.isEmpty(MapUtils.getString(skupResult, "secondhand_image")) && StringUtils.isNotEmpty(product_default_images)) {
skupResult.put("secondhand_image", product_default_images);
}
// 价格处理
// 3) 价格处理[现货最低价-skupPrice]
double skupPrice = MapUtils.getDoubleValue(skupResult, "skup_price", 0);
double available_now_price = MapUtils.getDoubleValue(productInfo, "available_now_price", 0);
double available_now_price = MapUtils.getDoubleValue(ufoProductInfo, "available_now_price", 0);
if (skupPrice > 0 && available_now_price > 0 && skupPrice < available_now_price) {
skupResult.put("save_price", available_now_price - skupPrice);
} else {
... ... @@ -104,7 +98,7 @@ public class UfoSecondhandSkupService {
}
});
// 7、构造返回结果
// 8、构造返回结果
JSONObject dataMap = new JSONObject();
dataMap.put("total", searchResult.getTotal());
dataMap.put("page", searchResult.getPage());
... ... @@ -119,10 +113,11 @@ public class UfoSecondhandSkupService {
private BoolQueryBuilder builderFilter(Map<String, String> paramMap) {
BoolQueryBuilder filter = QueryBuilders.boolQuery();
filter.must(QueryBuilders.rangeQuery("id").lte(MapUtils.getIntValue(paramMap, "maxStoragePriceId", Integer.MAX_VALUE)));
filter.must(QueryBuilders.rangeQuery("id").lte(MapUtils.getIntValue(paramMap, UfoSearchRequestParams.UFO_PARAM_MAXSTORAGEPRICE_ID, Integer.MAX_VALUE)));
filter.must(QueryBuilders.termQuery("isHide", 0));
filter.must(QueryBuilders.termQuery("status", 1));
List<Integer> preSaleFlags = SearchConvertUtils.stringToIntList(MapUtils.getString(paramMap, "preSaleFlag"), ",");
// 过滤preSaleFlag,默认5,6
List<Integer> preSaleFlags = SearchConvertUtils.stringToIntList(MapUtils.getString(paramMap, UfoSearchRequestParams.UFO_PARAM_PRE_SALE_FLAG), ",");
if (CollectionUtils.isNotEmpty(preSaleFlags)) {
filter.must(QueryBuilders.termsQuery("preSaleFlag", preSaleFlags));
} else {
... ...
... ... @@ -6,7 +6,6 @@ import com.yoho.search.aop.cache.SearchCacheAble;
import com.yoho.search.base.constants.ISearchConstants;
import com.yoho.search.cache.CacheInMinute;
import com.yoho.search.common.SearchCommonService;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.common.UfoSearchRequestParams;
import com.yoho.search.common.utils.SearchApiResultUtils;
import com.yoho.search.core.es.agg.IAggregation;
... ... @@ -80,7 +79,7 @@ public class UfoSelectionListService {
// 调用ES
SearchResult searchResult = searchCommonService.doSearch(productIndexName, searchParam);
// 正常查询结果为空,调用模糊纠错货号的逻辑去查
if (searchResult.getTotal() == 0 && paramMap.containsKey(UfoSearchRequestParams.UFOPRODUCTINDEX_SEARCH_QUERY)) {
if (searchResult.getTotal() == 0 && paramMap.containsKey(UfoSearchRequestParams.UFO_PARAM_SEARCH_QUERY)) {
searchParam = ufoFuzzySceneService.buildSearchParamForProductCodeSearch(paramMap, 0, 0);
searchParam.setAggregationBuilders(this.getAllAggregationBuilders(paramMap));
searchParam.setSize(0);
... ...
... ... @@ -5,7 +5,6 @@ import com.yoho.search.aop.cache.SearchCacheAble;
import com.yoho.search.base.constants.ISearchConstants;
import com.yoho.search.base.constants.ProductIndexEsField;
import com.yoho.search.common.SearchCommonService;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.common.UfoSearchRequestParams;
import com.yoho.search.common.utils.SearchKeyWordUtils;
import com.yoho.search.core.es.model.SearchParam;
... ... @@ -53,7 +52,7 @@ public class UfoSuggestService {
logger.info("[func=suggest][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis());
// 1)关键参数验证
String keyword = SearchKeyWordUtils.getUfoParamKeyword(paramMap, UfoSearchRequestParams.UFOPRODUCTINDEX_SEARCH_QUERY);
String keyword = SearchKeyWordUtils.getUfoParamKeyword(paramMap, UfoSearchRequestParams.UFO_PARAM_SEARCH_QUERY);
if (StringUtils.isBlank(keyword)) {
return new SearchApiResult().setCode(400).setMessage("关键字[query]参数为空!");
}
... ... @@ -61,7 +60,7 @@ public class UfoSuggestService {
if (keyword.length() > 30) {
return new SearchApiResult().setCode(400).setMessage("关键字[query]参数非法!");
}
paramMap.put(UfoSearchRequestParams.UFOPRODUCTINDEX_SEARCH_QUERY, keyword);
paramMap.put(UfoSearchRequestParams.UFO_PARAM_SEARCH_QUERY, keyword);
// 2)构建查询参数
SearchParam searchParam = this.buildSuggestSearchParam(paramMap);
... ... @@ -101,7 +100,7 @@ public class UfoSuggestService {
* 通过纠错的方式,查询建议词列表
*/
private SearchResult suggestByCorrectSpelling(Map<String, String> paramMap) {
String keyword = paramMap.get(UfoSearchRequestParams.UFOPRODUCTINDEX_SEARCH_QUERY).toLowerCase();
String keyword = paramMap.get(UfoSearchRequestParams.UFO_PARAM_SEARCH_QUERY).toLowerCase();
String newKeyword = (String) this.correctSpellingKeyword(paramMap).getData();
if (StringUtils.isEmpty(newKeyword)) {
return null;
... ... @@ -110,7 +109,7 @@ public class UfoSuggestService {
logger.info("Switch the suggest keyword from [{}] to [{}].", keyword, newKeyword);
Map<String, String> newParamMap = new HashMap<>(paramMap.size());
newParamMap.putAll(paramMap);
newParamMap.put(UfoSearchRequestParams.UFOPRODUCTINDEX_SEARCH_QUERY, newKeyword);
newParamMap.put(UfoSearchRequestParams.UFO_PARAM_SEARCH_QUERY, newKeyword);
SearchParam newSearchParam = this.buildSuggestSearchParam(newParamMap);
return searchCommonService.doSearch(ISearchConstants.INDEX_NAME_UFO_SUGGEST, newSearchParam);
} catch (Exception e) {
... ... @@ -123,7 +122,7 @@ public class UfoSuggestService {
* 构建查询参数
*/
private SearchParam buildSuggestSearchParam(Map<String, String> paramMap) {
String keyword = paramMap.get(UfoSearchRequestParams.UFOPRODUCTINDEX_SEARCH_QUERY).toLowerCase();
String keyword = paramMap.get(UfoSearchRequestParams.UFO_PARAM_SEARCH_QUERY).toLowerCase();
SearchParam searchParam = new SearchParam();
QueryBuilder query = QueryBuilders.boolQuery().should(QueryBuilders.prefixQuery("keyword", keyword)).should(QueryBuilders.prefixQuery("keyword.keyword_pinyin", keyword))
.should(QueryBuilders.prefixQuery("keyword.keyword_jianpin", keyword));
... ...