-
Notifications
You must be signed in to change notification settings - Fork 233
Elasticsearch as a data store
Devender Yadav edited this page Dec 19, 2018
·
5 revisions
Being a JPA provider, Kundera provides support for Elasticseach.
Kundera Elasticsearch mapping -
JPA attribute | Elasticsearch attribute |
---|---|
Schema Name | Index Name |
Table Name | Index Type |
Primary Key | Index Id |
<persistence-unit name="es-pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<properties>
<property name="kundera.nodes" value="localhost" />
<property name="kundera.port" value="9300" />
<property name="kundera.keyspace" value="esSchema" />
<property name="kundera.dialect" value="es" />
<property name="kundera.client.lookup.class" value="com.impetus.client.es.ESClientFactory" />
</properties>
</persistence-unit>
@Entity
@Table(name = "BOOK", schema = "esSchema@es-pu")
public class Book
{
@Id
@Column(name = "BOOK_ID")
private int bookId;
@Column(name = "TITLE")
private String title;
@Column(name = "AUTHOR")
private String author;
@Column(name = "NUM_PAGES")
private int numPages;
// getters and setters
}
EntityManagerFactory emf = Persistence.createEntityManagerFactory("es-pu");
EntityManager em = emf.createEntityManager();
Book b = new Book();
b.setBookId(101);
b.setAuthor("George R. R. Martin");
b.setTitle("A Game of Thrones");
b.setNumPages(694);
em.persist(b);
This book object in persisted in Elasticsearch under esSchema
schema, BOOK
index with 101 id.