Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Batch and ElasticSearch

Here is my scenario..

I need to read csv file and store output to ElasticSearch. I am using Spring Batch to read csv file. can anyone give me example how to save in elasticsearch using Spring Batch or Spring Batch Extension?

like image 634
Rakesh Avatar asked Mar 04 '26 14:03

Rakesh


1 Answers

Its an old question and probably you might have found answer by now but here it goes...

To work with ElasticSearch, you need Spring Data and you simply write items from your writer as you normally do but with a repository instance like - repository.save(list) where list is a List of items passed from Spring Batch processor to writer.

Where repository is basically a ElasticsearchRepository from Spring Data. You need to define repositories for your items.

You need to provide your ElasticsearchRepository definitions to ElasticSearch instance definitions by editing - @EnableElasticsearchRepositories in and you define persistent layer as done here. Edit @EnableElasticsearchRepositories to actual repository package location of your project.

Hope it helps !!

like image 194
Sabir Khan Avatar answered Mar 06 '26 12:03

Sabir Khan