Reputation: 21
I want to ask if it is possible to use spring-data-elasticsearch in conjonction with Mysql Database. For example the store of items will be with this flow elastic-search <==> spring-data <==> Mysql Database
Upvotes: 2
Views: 2314
Reputation: 111
No You can not use Spring Data Elasticsearch to do your database operations on MySQL. The name itself states that this Spring Data Technology is an implementation for the Elasticsearch. To do the Database part you will require a Java persistence technology(eg. Hibernate)
Upvotes: 0
Reputation: 3883
My solution is, define the entity as document
like:
@Entity
@Table(name = "user")
@Document(indexName = "user")
public class User {....}
Define a UserRepository
of spring-data
, and a UserSearchRepository
of spring-data-elasticSearch separately.
When I create a new user, add index with UserSearchRepository.save(user)
at the same time. Do the same when update or delete.
Upvotes: 5