I've written a reindex method that does the following:
public void reindex() {
IndexOperations indexOperations = elasticsearchOperations.indexOps(Song.class);
List<Song> songs = songRepository.findAll();
songSearchRepository.deleteAll();
indexOperations.delete();
indexOperations.create();
songSearchRepository.saveAll(songs);
}
It does the job but I'm now sure whether it makes sence just to delete and then create an index. How can I improve this method?