...
|
...
|
@@ -65,10 +65,12 @@ public class SearchLikeSceneService { |
|
|
|
|
|
// 4、设置第一步SearchParam
|
|
|
String isGlobalInEs = productInfoInEs.getString(ProductIndexEsField.isGlobal);
|
|
|
String isUfoInEs = productInfoInEs.getString(ProductIndexEsField.isUfo);
|
|
|
boolean isGlobal = "Y".equalsIgnoreCase(isGlobalInEs);
|
|
|
boolean isUfo = "Y".equalsIgnoreCase(isUfoInEs);
|
|
|
List<SearchParam> searchParams = new ArrayList<SearchParam>();
|
|
|
searchParams.add(this.buildSearchParam(productInfoInEs, 5, true, isGlobal));// 固定取同品牌的5个商品
|
|
|
searchParams.add(this.buildSearchParam(productInfoInEs, pageSize, false, isGlobal));
|
|
|
searchParams.add(this.buildSearchParam(productInfoInEs, 5, true, isGlobal,isUfo));// 固定取同品牌的5个商品
|
|
|
searchParams.add(this.buildSearchParam(productInfoInEs, pageSize, false, isGlobal,isUfo));// 取同品牌的5个商品
|
|
|
|
|
|
// 5、获取搜索结果[并截取条数]
|
|
|
List<Map<String, Object>> tempProductList = searchLikeHelper.queryProductList(searchParams);
|
...
|
...
|
@@ -103,16 +105,16 @@ public class SearchLikeSceneService { |
|
|
* @param isGlobal
|
|
|
* @return
|
|
|
*/
|
|
|
private SearchParam buildSearchParam(JSONObject productInfoInEs, int limitCount, boolean inBrand, boolean isGlobal) {
|
|
|
private SearchParam buildSearchParam(JSONObject productInfoInEs, int limitCount, boolean inBrand, boolean isGlobal,boolean isUfo) {
|
|
|
SearchParam searchParam = new SearchParam();
|
|
|
|
|
|
// 1、构建Query
|
|
|
QueryBuilder queryBuilder = this.buildCharsetQueryBuilder(productInfoInEs, inBrand, isGlobal);
|
|
|
QueryBuilder queryBuilder = this.buildCharsetQueryBuilder(productInfoInEs, inBrand, isGlobal,isUfo);
|
|
|
searchParam.setQuery(queryBuilder);
|
|
|
|
|
|
// 2、设置过滤条件
|
|
|
List<String> notProductSkns = Arrays.asList(productInfoInEs.getString(ProductIndexEsField.productSkn));
|
|
|
BoolQueryBuilder booleanQueryBuilder = this.genSearchLikeFilterBuilder(productInfoInEs, notProductSkns, inBrand, isGlobal);
|
|
|
BoolQueryBuilder booleanQueryBuilder = this.genSearchLikeFilterBuilder(productInfoInEs, notProductSkns, inBrand, isGlobal, isUfo);
|
|
|
searchParam.setFiter(booleanQueryBuilder);
|
|
|
|
|
|
// 3、设置排序规则[按打分排序]
|
...
|
...
|
@@ -137,8 +139,8 @@ public class SearchLikeSceneService { |
|
|
* @param isGlobal
|
|
|
* @return
|
|
|
*/
|
|
|
private BoolQueryBuilder genSearchLikeFilterBuilder(JSONObject productInfoInEs, List<String> notProductSkns, boolean isInBrand, boolean isGlobal) {
|
|
|
BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(notProductSkns, isInBrand ? isGlobal : false);// 前几个是全球购,后面找有货的就好
|
|
|
private BoolQueryBuilder genSearchLikeFilterBuilder(JSONObject productInfoInEs, List<String> notProductSkns, boolean isInBrand, boolean isGlobal,boolean isUfo) {
|
|
|
BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(notProductSkns, isInBrand ? isGlobal : false,isInBrand ? isUfo : false);// 前几个是全球购,后面找有货的就好
|
|
|
// 1)设置此SKN相关的过滤条件
|
|
|
String gender = productInfoInEs.getString(ProductIndexEsField.gender);
|
|
|
List<String> genderList = searchLikeHelper.getGenderInfo(gender);
|
...
|
...
|
@@ -177,9 +179,9 @@ public class SearchLikeSceneService { |
|
|
* @param isGlobal
|
|
|
* @return
|
|
|
*/
|
|
|
private QueryBuilder buildCharsetQueryBuilder(JSONObject productInfoInEs, boolean isInBrand, boolean isGlobal) {
|
|
|
private QueryBuilder buildCharsetQueryBuilder(JSONObject productInfoInEs, boolean isInBrand, boolean isGlobal,boolean isUfo){
|
|
|
// 1、如果是全球购,则直接用商品名称+品类名称去查
|
|
|
if (isGlobal) {
|
|
|
if (isGlobal || isUfo) {
|
|
|
String queryString = searchLikeHelper.genGlobalQueryString(productInfoInEs);
|
|
|
return searchLikeHelper.buildCharsetQueryBuilder(queryString, "25%");
|
|
|
}
|
...
|
...
|
@@ -251,7 +253,7 @@ public class SearchLikeSceneService { |
|
|
searchParam.setQuery(queryBuilder);
|
|
|
|
|
|
// 2、设置过滤条件
|
|
|
BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(Arrays.asList(productInfoInEs.getString("productSkn")), false);
|
|
|
BoolQueryBuilder boolFilter = searchLikeHelper.genDefaultSearchLikeFilter(Arrays.asList(productInfoInEs.getString("productSkn")), false,false);
|
|
|
boolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.storeShowStatus, Arrays.asList("1", "2")));
|
|
|
|
|
|
// 3、找相似要具体到到中分类或小分类,大分类范围太广
|
...
|
...
|
|