# 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:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![fdb58704a2c5cc6a3286](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@fdb58704a2c5cc6a3286](https://discuss.elastic.co/u/fdb58704a2c5cc6a3286)
#### Post date: [October 26, 2018, 5:43am UTC](https://discuss.elastic.co/t/synchronize-data-to-es-and-customize-es-index-structure/154098/1 "2018-10-26T05:43:04Z")

</div>

i have two table: `customer,customer_order` customer have customer\_name,sex,customerid columns. and i want synchronize the two table to elasticsearch `customerOrder` index the customerOrder structure like

```auto
{
  orderid:x,
  ordercreatetime,
  customerinfo:{
    customername:xx,
    sex:x
    customerid:xx
  }
}

```

my question is ,how to make two table data to synchronize and integration to customed es index structure like: `customerOrder` and when customer\_name changed in customer table,i want to change all customerOrder index's customername field value. thanks all your suggestion!

---

<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 }  
}

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 23, 2018, 5:54am UTC](https://discuss.elastic.co/t/synchronize-data-to-es-and-customize-es-index-structure/154098/3 "2018-11-23T05:54:44Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
