# MySQL Syncing with Logstash to Elasticsearch

**URL:** <https://discuss.elastic.co/t/mysql-syncing-with-logstash-to-elasticsearch/109269>\
**Category:** Logstash\
**Created:** [November 27, 2017, 6:30pm UTC](https://discuss.elastic.co/t/mysql-syncing-with-logstash-to-elasticsearch/109269 "2017-11-27T18:30:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moomba](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/moomba/32/24732_2.png) [@Moomba](https://discuss.elastic.co/u/Moomba)\
**Post date:** [November 27, 2017, 6:30pm UTC](https://discuss.elastic.co/t/mysql-syncing-with-logstash-to-elasticsearch/109269/1 "2017-11-27T18:30:47Z")

</div>

Hello,

For the last few hours i have been trying to implement synchronisation between MySQL database and Elasticsearch using Logstash and the JDBC plugin.  
Each row in each table has a updated\_at column (timestamp, refreshed when something changes in the row), created\_at column (timestamp, only set when the row is created) and a deleted column (boolean, set to true when the backend - play framework - deletes something, no hard deletes).  
What i want to do is _ **query all rows from all tables that have been updated / created** _ since the last check, and _ **add** _ those that have been just created (_created\_at \> last check_), _ **update** _ existing documents (_updated\_at \> last check_) and _ **delete** _ those that have their deleted flag set to true and _updated\_at \> last check_.  
Im having a real trouble figuring out how to do this and any help, links or pointers would be appreciated 🙂

PS: If i understand correctly each table should have its own index, right? All examples on the internet only check one table 😕

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 28, 2017, 6:31am UTC](https://discuss.elastic.co/t/mysql-syncing-with-logstash-to-elasticsearch/109269/2 "2017-11-28T06:31:17Z")

</div>

Is the updated\_at column set for newly created documents, i.e. do you actually need to care about created\_at?

---

<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:** [December 26, 2017, 6:31am UTC](https://discuss.elastic.co/t/mysql-syncing-with-logstash-to-elasticsearch/109269/3 "2017-12-26T06:31:45Z")

</div>

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