Reputation: 177
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?
Upvotes: 3
Views: 5023
Reputation: 2233
Actually, I worked with a similar project but instead of importing data from a CSV file, I imported it from a relational database MySQL, reading and filtering data with the spring batch and write it into elasticsearch , this is the link of the project in the GitHub read carefully the readme.md file you will find all the required configuration :
Upvotes: 0
Reputation: 10142
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 !!
Upvotes: 2