fix: 优化商品根据id搜索

This commit is contained in:
misworga831 2023-02-04 11:13:32 +08:00
parent 475f96d00a
commit 9e1837e89c

View File

@ -913,8 +913,10 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
if (CollUtil.isNotEmpty(categoryList) && CharSequenceUtil.isNotEmpty(goodsSku.getCategoryPath())) { if (CollUtil.isNotEmpty(categoryList) && CharSequenceUtil.isNotEmpty(goodsSku.getCategoryPath())) {
StringBuilder categoryNamePath = new StringBuilder(); StringBuilder categoryNamePath = new StringBuilder();
categoryList.stream().filter(o -> goodsSku.getCategoryPath().contains(o.get("id").toString())).forEach(p -> categoryNamePath.append(p.get("name")).append(",")); categoryList.stream().filter(o -> goodsSku.getCategoryPath().contains(o.get("id").toString())).forEach(p -> categoryNamePath.append(p.get("name")).append(","));
categoryNamePath.deleteCharAt(categoryNamePath.length() - 1); if (CharSequenceUtil.isNotEmpty(categoryNamePath)) {
index.setCategoryNamePath(categoryNamePath.toString()); categoryNamePath.deleteCharAt(categoryNamePath.length() - 1);
index.setCategoryNamePath(categoryNamePath.toString());
}
} }
//商品品牌索引 //商品品牌索引
if (CollUtil.isNotEmpty(brandList) && CharSequenceUtil.isNotEmpty(goodsSku.getBrandId())) { if (CollUtil.isNotEmpty(brandList) && CharSequenceUtil.isNotEmpty(goodsSku.getBrandId())) {
@ -928,8 +930,10 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
if (CollUtil.isNotEmpty(storeCategoryList) && CharSequenceUtil.isNotEmpty(goodsSku.getStoreCategoryPath())) { if (CollUtil.isNotEmpty(storeCategoryList) && CharSequenceUtil.isNotEmpty(goodsSku.getStoreCategoryPath())) {
StringBuilder storeCategoryNamePath = new StringBuilder(); StringBuilder storeCategoryNamePath = new StringBuilder();
storeCategoryList.stream().filter(o -> goodsSku.getStoreCategoryPath().contains(o.get("id").toString())).forEach(p -> storeCategoryNamePath.append(p.get("label_name").toString()).append(",")); storeCategoryList.stream().filter(o -> goodsSku.getStoreCategoryPath().contains(o.get("id").toString())).forEach(p -> storeCategoryNamePath.append(p.get("label_name").toString()).append(","));
storeCategoryNamePath.deleteCharAt(storeCategoryNamePath.length() - 1); if (CharSequenceUtil.isNotEmpty(storeCategoryNamePath)) {
index.setStoreCategoryNamePath(storeCategoryNamePath.toString()); storeCategoryNamePath.deleteCharAt(storeCategoryNamePath.length() - 1);
index.setStoreCategoryNamePath(storeCategoryNamePath.toString());
}
} }
return index; return index;
} }