From b860c2eed0f97de04ef5495b3abf752cd8164b0b Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 2 Aug 2022 10:52:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/EsGoodsIndexServiceImpl.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index a2054507..1d3ed8ca 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -296,20 +296,15 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements //根据商品名称生成分词 keywordsList.add(goods.getGoodsName().substring(0, Math.min(goods.getGoodsName().length(), 10))); - //如果有分词 - if (!keywordsList.isEmpty()) { - //去除重复词 - removeDuplicate(keywordsList); - //入库自定义分词 - List customWordsArrayList = new ArrayList<>(); - keywordsList.stream().forEach(item -> { - customWordsArrayList.add(new CustomWords(item)); - }); - //这里采用先批量删除再插入的方法,故意这么做。否则需要挨个匹配是否存在,性能消耗更大 - if (CollUtil.isNotEmpty(customWordsArrayList)) { - customWordsService.deleteBathByName(keywordsList); - customWordsService.insertBatchCustomWords(customWordsArrayList); - } + //去除重复词 + removeDuplicate(keywordsList); + //入库自定义分词 + List customWordsArrayList = new ArrayList<>(); + keywordsList.forEach(item -> customWordsArrayList.add(new CustomWords(item))); + //这里采用先批量删除再插入的方法,故意这么做。否则需要挨个匹配是否存在,性能消耗更大 + if (CollUtil.isNotEmpty(customWordsArrayList)) { + customWordsService.deleteBathByName(keywordsList); + customWordsService.insertBatchCustomWords(customWordsArrayList); } } catch (Exception e) { log.info(goods + "自定义分词错误", e);