优化结构
This commit is contained in:
parent
fdf81d1b39
commit
b860c2eed0
@ -296,21 +296,16 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
|||||||
//根据商品名称生成分词
|
//根据商品名称生成分词
|
||||||
keywordsList.add(goods.getGoodsName().substring(0, Math.min(goods.getGoodsName().length(), 10)));
|
keywordsList.add(goods.getGoodsName().substring(0, Math.min(goods.getGoodsName().length(), 10)));
|
||||||
|
|
||||||
//如果有分词
|
|
||||||
if (!keywordsList.isEmpty()) {
|
|
||||||
//去除重复词
|
//去除重复词
|
||||||
removeDuplicate(keywordsList);
|
removeDuplicate(keywordsList);
|
||||||
//入库自定义分词
|
//入库自定义分词
|
||||||
List<CustomWords> customWordsArrayList = new ArrayList<>();
|
List<CustomWords> customWordsArrayList = new ArrayList<>();
|
||||||
keywordsList.stream().forEach(item -> {
|
keywordsList.forEach(item -> customWordsArrayList.add(new CustomWords(item)));
|
||||||
customWordsArrayList.add(new CustomWords(item));
|
|
||||||
});
|
|
||||||
//这里采用先批量删除再插入的方法,故意这么做。否则需要挨个匹配是否存在,性能消耗更大
|
//这里采用先批量删除再插入的方法,故意这么做。否则需要挨个匹配是否存在,性能消耗更大
|
||||||
if (CollUtil.isNotEmpty(customWordsArrayList)) {
|
if (CollUtil.isNotEmpty(customWordsArrayList)) {
|
||||||
customWordsService.deleteBathByName(keywordsList);
|
customWordsService.deleteBathByName(keywordsList);
|
||||||
customWordsService.insertBatchCustomWords(customWordsArrayList);
|
customWordsService.insertBatchCustomWords(customWordsArrayList);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info(goods + "自定义分词错误", e);
|
log.info(goods + "自定义分词错误", e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user