...
|
...
|
@@ -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());
|
...
|
...
|
|