|
@@ -131,7 +131,7 @@ public class SearchLikeInShopService { |
|
@@ -131,7 +131,7 @@ public class SearchLikeInShopService { |
131
|
// 1、设置SearchParam
|
131
|
// 1、设置SearchParam
|
132
|
SearchParam searchParam = new SearchParam();
|
132
|
SearchParam searchParam = new SearchParam();
|
133
|
// 2)设置query和filter
|
133
|
// 2)设置query和filter
|
134
|
- searchParam.setFiter(this.builderSearchLikeInShopFilter(productInfoInEs, productSkns));
|
134
|
+ searchParam.setFiter(this.builderSearchLikeInShopFilter(productInfoInEs, productSkns, true));
|
135
|
// 3、设置分页参数
|
135
|
// 3、设置分页参数
|
136
|
searchParam.setOffset(0);
|
136
|
searchParam.setOffset(0);
|
137
|
searchParam.setSize(productSkns.size());
|
137
|
searchParam.setSize(productSkns.size());
|
|
@@ -153,7 +153,7 @@ public class SearchLikeInShopService { |
|
@@ -153,7 +153,7 @@ public class SearchLikeInShopService { |
153
|
SearchParam searchParam = new SearchParam();
|
153
|
SearchParam searchParam = new SearchParam();
|
154
|
// 2)设置query和filter
|
154
|
// 2)设置query和filter
|
155
|
searchParam.setQuery(this.buildeCharactersQueryBuilder(productInfoInEs, "20%"));
|
155
|
searchParam.setQuery(this.buildeCharactersQueryBuilder(productInfoInEs, "20%"));
|
156
|
- searchParam.setFiter(this.builderSearchLikeInShopFilter(productInfoInEs, null));
|
156
|
+ searchParam.setFiter(this.builderSearchLikeInShopFilter(productInfoInEs, null, false));
|
157
|
// 3、设置排序规则[按打分排序]
|
157
|
// 3、设置排序规则[按打分排序]
|
158
|
List<SortBuilder<?>> sortBuilders = new ArrayList<>();
|
158
|
List<SortBuilder<?>> sortBuilders = new ArrayList<>();
|
159
|
sortBuilders.add(SortBuilders.scoreSort().order(SortOrder.DESC));
|
159
|
sortBuilders.add(SortBuilders.scoreSort().order(SortOrder.DESC));
|
|
@@ -173,14 +173,13 @@ public class SearchLikeInShopService { |
|
@@ -173,14 +173,13 @@ public class SearchLikeInShopService { |
173
|
return queryBuilder;
|
173
|
return queryBuilder;
|
174
|
}
|
174
|
}
|
175
|
|
175
|
|
176
|
- private BoolQueryBuilder builderSearchLikeInShopFilter(JSONObject productInfoInEs, List<String> inProductSkns) {
|
176
|
+ private BoolQueryBuilder builderSearchLikeInShopFilter(JSONObject productInfoInEs, List<String> inProductSkns, boolean needSameSort) {
|
177
|
//1) 默认参数
|
177
|
//1) 默认参数
|
178
|
String productSkn = productInfoInEs.getString(ProductIndexEsField.productSkn);
|
178
|
String productSkn = productInfoInEs.getString(ProductIndexEsField.productSkn);
|
179
|
String isGlobalInEs = productInfoInEs.getString(ProductIndexEsField.isGlobal);
|
179
|
String isGlobalInEs = productInfoInEs.getString(ProductIndexEsField.isGlobal);
|
180
|
boolean isGlobal = "Y".equalsIgnoreCase(isGlobalInEs);
|
180
|
boolean isGlobal = "Y".equalsIgnoreCase(isGlobalInEs);
|
181
|
BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(Arrays.asList(productSkn), isGlobal);
|
181
|
BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(Arrays.asList(productSkn), isGlobal);
|
182
|
|
182
|
|
183
|
-
|
|
|
184
|
// 2)设置此SKN相关的性别过滤条件
|
183
|
// 2)设置此SKN相关的性别过滤条件
|
185
|
String gender = productInfoInEs.getString(ProductIndexEsField.gender);
|
184
|
String gender = productInfoInEs.getString(ProductIndexEsField.gender);
|
186
|
List<String> genderList = searchLikeHelper.getGenderInfo(gender);
|
185
|
List<String> genderList = searchLikeHelper.getGenderInfo(gender);
|
|
@@ -202,8 +201,13 @@ public class SearchLikeInShopService { |
|
@@ -202,8 +201,13 @@ public class SearchLikeInShopService { |
202
|
boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, inProductSkns));
|
201
|
boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, inProductSkns));
|
203
|
}
|
202
|
}
|
204
|
|
203
|
|
|
|
204
|
+ // 5)同品类
|
|
|
205
|
+ Integer middleSortId = productInfoInEs.getInteger(ProductIndexEsField.middleSortId);
|
|
|
206
|
+ if (needSameSort && searchLikeHelper.isLegalInteger(middleSortId)) {
|
|
|
207
|
+ boolFilter.must(QueryBuilders.termQuery(ProductIndexEsField.middleSortId, middleSortId));
|
|
|
208
|
+ }
|
|
|
209
|
+
|
205
|
return boolFilter;
|
210
|
return boolFilter;
|
206
|
}
|
211
|
}
|
207
|
|
212
|
|
208
|
-
|
|
|
209
|
} |
213
|
} |