Easy-Es Easy-Es
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)

adv display by random ❤️become sponsor
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)
  • Quick start

    • Introduction.md
    • Applicable scene
    • Worry free
    • Avoid pit
    • Quick start
    • Springboot demo
    • Spring Integration Guide
    • Solon Integration Guide
    • Config
    • Annotation
  • Core function

    • Condition constructor

      • Introduction of Wrapper
      • Index wrapper
      • Select wrapper
      • Update wrapper
    • Index CRUD

      • Index hosting model
      • Index CRUD
    • Data CRUD

      • Data synchronization solutions
        • Background
        • Full synchronization
        • Incremental synchronization
      • Data CRUD
    • Multiple data sources support
    • Dynamic indexing support
    • Four nested query
    • Chain call
  • Extended function

    • Mixed query
    • Origin query
    • Page
    • Nested
    • Join parent child
    • Get DSL
    • ExecuteDSL
    • Execute SQL
    • Custom RequestOptions
    • Custom default method
  • High-level syntax

    • Field filtering
    • Sort
    • Aggregation
    • Match&fuzzy match
    • Weight
    • Highlight
    • Geo
    • IP
  • Plugin

    • Plugin
  • Other

    • Faq
    • Difference from MP
    • MySQL and EE syntax comparison
    • Update log
    • Update plan
    • Copyright
    • Thanks
  • v2.xDoc
  • Core function
  • Data CRUD
LaoHan
2023-03-18
目录

Data synchronization solutions

# Background

Many friends asked me in the community Q&A group how to synchronize data from MySQL to ES. To answer this question well, we need to combine specific business scenarios and data volume to And the specific number of developers, different situations have different plans, just like cooking with salt, I can't answer you directly, I can only give some feasible plans. Users can consider the situation of their own company comprehensively.

# Full synchronization

As the name implies, it is to synchronize all the data in the existing database to ES. Usually, when accessing ES for the first time, it is necessary to initialize all the data. Full synchronization can Consider the official Logstash of ES and the open source DataX of Ali. Of course, if your data volume is less than 10 million, and the data itself is relatively small, you want to make it simple. Save trouble, it is not bad to insert in batches by using the insertBatch(Collection data) method provided by Easy-Es.

# Incremental synchronization

When the full data synchronization is completed, users start to use ES, and then with the CRUD of this data, we need to synchronize the changes of these data to ES to ensure the ES. The data effectiveness is called incremental synchronization. A mature solution is the open source Canal of Ali, but you can also use MQ or even local message events (for example. Guava's Event-Bus,springboot's own Event), according to the number of your business and whether the deployment machine is distributed environment, etc. Suitable solutions, the above solutions are similar in principle, basically publish messages when MySQL data changes (add/delete/modify), and then the subscribers subscribe to the consumer. After the event, synchronize the data changes to ES, so that you can decouple. If your concurrency is not too high and the data volume changes little, use Easy-Es to provide it. Batch CRUD method is also acceptable. You can find out the changed data from MP and then call the API below to complete the data change. The API below is the same as MP, so it will not be introduced again.

Integer updateBatchByIds(Collection<T> entityList);
Integer deleteBatchIds(Collection<? extends Serializable> idList);
Integer insertBatch(Collection<T> entityList);
Integer delete(Wrapper<T> wrapper);
1
2
3
4

提示

Before the formal synchronization, please plan and design your index structure, fragments and copies, etc., because the ES index has to be rebuilt after it changes. Relocation of data is time-consuming and labor-intensive, so don't rush it, or you may go back to before liberation overnight!

In addition, the above schemes are all reference schemes. If you find a better solution, you are welcome to try it, and I won't introduce each scheme here. Implementation, are mature open source components, we will not ask Du Niang or ChatGPT.

Help us improve this document (opens new window)
Last update: 2024/03/29
Index CRUD
Data CRUD

← Index CRUD Data CRUD→

Theme by Vdoing | Copyright © 2021-2025 LaoHan | Zhejiang ICP No. 2022020479 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式