# Synchronize data to es and customize es index structure

**URL:** https://discuss.elastic.co/t/synchronize-data-to-es-and-customize-es-index-structure/154098
**Category:** Logstash
**Created:** [October 26, 2018, 5:43am UTC](https://discuss.elastic.co/t/synchronize-data-to-es-and-customize-es-index-structure/154098 "2018-10-26T05:43:04Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)
#### Post date: [October 26, 2018, 5:54am UTC](https://discuss.elastic.co/t/synchronize-data-to-es-and-customize-es-index-structure/154098/2 "2018-10-26T05:54:43Z")

</div>

use below input code to connect to databse and load data from both the tables,

in case of "statement", write join query to retrieve data from both tables,

input {

jdbc {  
jdbc\_driver\_library =\> "D:/Softwares/logstash-6.4.2/lib/com.mysql.jdbc\_5.1.5.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
jdbc\_connection\_string =\> "jdbc:mysql://localhost:3306/test"  
jdbc\_user =\> "root"  
jdbc\_password =\> "root"  
statement =\> "SELECT \* FROM sample"  
jdbc\_paging\_enabled =\> "true"  
jdbc\_page\_size =\> "50000"  
}

}

output{  
elasticsearch { codec =\> json hosts =\> ["localhost:9200"] index =\> "mysqldata" }  
stdout { codec =\> rubydebug }  
}

---

_[View the full topic](https://discuss.elastic.co/t/synchronize-data-to-es-and-customize-es-index-structure/154098)._
