优化consumer生成商品索引。改为批量生成

This commit is contained in:
paulGao
2022-04-25 10:26:51 +08:00
parent 0354d6dc3e
commit aa185c8bd2
3 changed files with 25 additions and 6 deletions

View File

@@ -38,6 +38,13 @@ public interface EsGoodsIndexService {
*/
void addIndex(EsGoodsIndex goods);
/**
* 添加商品索引
*
* @param goods 商品索引信息
*/
void addIndex(List<EsGoodsIndex> goods);
/**
* 更新商品索引
*

View File

@@ -210,6 +210,20 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
}
}
/**
* 添加商品索引
*
* @param goods 商品索引信息
*/
@Override
public void addIndex(List<EsGoodsIndex> goods) {
try {
goodsIndexRepository.saveAll(goods);
} catch (Exception e) {
log.error("批量为商品生成索引异常", e);
}
}
@Override
public void updateIndex(EsGoodsIndex goods) {
goodsIndexRepository.save(goods);