我该怎么做才能获得从 mysql 到 elasticsearch 的实时更新

what do i do to get real time update from mysql to elasticsearch

我根据以下内容创建了一个供稿器脚本:https://github.com/jprante/elasticsearch-jdbc/wiki/jdbc-plugin-feeder-mode-as-an-alternative-to-the-deprecated-elasticsearch-river-api

我没有向上面的示例添加任何新属性(当然更改了数据库设置等)。 table 的索引非常快,然后馈线脚本正常终止。我需要做什么才能使馈线脚本持久化并在新记录添加到数据库时(近)实时地从 mysql 数据库获取更新?

谢谢

更新:

elasticsearch版本为1.4.4,安装了插件river和head。

您有多种选择来获得近乎实时的行为,但它需要一些成本。

  1. 显式触发索引刷新

可以在所有数据写入后完成。

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html

  1. 配置索引刷新时间

您可以将索引刷新时间设置为较短的时间跨度。

{
  "settings": {
    "refresh_interval": "1s" 
  }
}

有关详细信息,请参阅:https://www.elastic.co/guide/en/elasticsearch/guide/current/near-real-time.html

感谢大家的关注。

我最终决定在 DB 和 ES 中创建文档。在我获得新文档中的任何值之前(在索引中创建文档之后),我正在刷新索引。我知道这不是 "ideal" 情况,但现在可以解决我的问题。