简体   繁体   English

删除弹性搜索河插件中未更新的记录

[英]Delete records not updating in elastic search river plugin

In elastic search river , if i deleted a record in mysql , its still showing in index . 在弹性搜索河中,如果我删除了mysql中的一条记录,它仍显示在索引中。 I have enabled auto-commit also . 我也启用了自动提交。 How make mysql and elastic search in sync and also how to make delta-imports in elastic ? 如何使mysql和弹性搜索同步,以及如何使delta导入在弹性?

   {
"type" : "jdbc",
"jdbc" : {
    "driver" : "com.mysql.jdbc.Driver",
    "url" : "jdbc:mysql://localhost:3306/testrivet",
    "user" : "root",
    "password" : "Gemini*123",
    "sql" : [
                        { 
                             "statement" : "select *,empid as _id from empdata"

                        }
       ],
    "strategy" : "simple",
 "schedule" : "0 0-59 0-23 ? * *",
 "autocommit" : true,
 "metrics": {enabled:true}
    },
    "index" : {
   "autocommit":true
    }
}

Indeed, if a record is deleted from your database, there's no way your JDBC river will be able to retrieve it anymore in order to delete the corresponding record in ES. 实际上,如果从数据库中删除了一条记录,那么您的JDBC河将无法再检索它以删除ES中的相应记录。

An alternative is to "soft-delete" records from your database by setting a flag (ie a new boolean column). 一种替代方法是通过设置标志(即新的布尔列)从数据库中“软删除”记录。 The flag would be true when the record is active and false when the record is deleted. 当记录处于活动状态时,该标志为true;当删除记录时,该标志为false。 That way when your import process runs, you'd get all records and based on that flag you know you have to delete the documents from Elasticsearch. 这样,当您的导入过程运行时,您将获得所有记录,并根据该标志知道必须从Elasticsearch中删除文档。

There are other ways but they involve adding another component to the mix, so if this would do the job I'd suggest doing like that. 还有其他方法,但是它们涉及将其他成分添加到混合中,因此,如果这样做可以做,我建议您这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM