【发布时间】:2020-10-14 09:06:21
【问题描述】:
我编写了一个 reindex 方法,它执行以下操作:
public void reindex() {
IndexOperations indexOperations = elasticsearchOperations.indexOps(Song.class);
List<Song> songs = songRepository.findAll();
songSearchRepository.deleteAll();
indexOperations.delete();
indexOperations.create();
songSearchRepository.saveAll(songs);
}
它完成了这项工作,但我现在确定删除然后创建索引是否有意义。我该如何改进这种方法?
【问题讨论】: