Elasticsearch MySQL incremental sync three-table federated script

Source: Internet
Author: User

Briefly in the previous article about the ES synchronization data script roughly, but the actual situation is certainly not as simple as the script in the previous article. For example, I now have three tables, two entity tables, and an association table. The approximate implementation is as follows:

The bin directory establishes a Statefile.json file:

{    ' type ': ' JDBC ',    "Statefile": "Statefile.json",   "JDBC": {        "url": "jdbc:mysql://",        "User": "",        "Password": "",        ' Type ': ' Actor ',        "Index": "Test",           "Schedule": "0 * * * *?",        "Metrics" : {       "Lastexecutionstart": "0",      "Lastexecutionend": "0",      "Counter": "1"     },                 "SQL" : [            {                "Statement": "Select a.actor_id as _id, A.*,group_concat (b.tag_name) as Tag_name from ((Gd_actor_info as a LEFT join Gd_actor_tag as AB on a.actor_id = ab.actor_id) left join Gd_tag_actor as B on ab.tag_id = b.tag_id) where A.update_tim e;? or Ab.update_time >? GROUP BY a.actor_id ",                "Parameter": ["$metrics. Lastexecutionstart", "$metrics. Lastexecutionstart" ]            }        ]          }}

The main lastexecutionstart is set to 0, in order for the first execution to be able to perform a full-scale backup.

In fact, the SH script information is on the top, and then write a good

Elasticsearch MySQL incremental sync three-table federated script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.