简体   繁体   English

在 Elastic Search 中同步 JSON 数据

[英]Synchronizing JSON data in Elastic Search

I have a JSON file data which is updated continuously (after every hour).我有一个 JSON 文件数据,它不断更新(每小时之后)。 What would be the best approach to synchronize this data with elastic search's index?将此数据与弹性搜索的索引同步的最佳方法是什么?

What I am doing at the moment?我现在在做什么? I just delete and add index again and it is not a good approach for live version of my application.我只是删除并再次添加索引,这对于我的应用程序的实时版本来说不是一个好方法。

What best approach would you people suggest?你会建议什么最好的方法?

I don't think that your approach is completely wrong.我不认为你的方法是完全错误的。 However, if you need to retain availability, it's best to use index aliases .但是,如果您需要保留可用性,最好使用索引别名 Think of alias as a symlink to the index.将别名视为索引的符号链接。 From the documentation:从文档:

The index aliases API allows aliasing an index with a name, with all APIs automatically converting the alias name to the actual index name.索引别名 API 允许使用名称为索引设置别名,所有 API 都会自动将别名转换为实际的索引名称。

Initially, you index your documents (from the JSON file) to some index, let's say data-2019-04-29-08-00 (named based on the date and time), and create an alias data for this index.最初,您将文档(来自 JSON 文件)索引到某个索引,例如data-2019-04-29-08-00 (根据日期和时间命名),并为此索引创建别名data You target all your queries against the data alias.您针对data别名定位所有查询。 When your data (JSON file) change the next hour, you index the data into a new index, data-2019-04-29-09-00 and change the data alias to point to this new index.当您的数据(JSON 文件)在下一小时发生变化时,您将数据索引到一个新索引data-2019-04-29-09-00 ,并将data别名更改为指向这个新索引。 Now all the queries will work with the new data.现在所有查询都将使用新数据。 This way, no matter how long indexing the documents take, you won't suffer any outage as changing the alias is a really fast operation.这样,无论索引文档需要多长时间,您都不会遇到任何中断,因为更改别名是一项非常快速的操作。

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

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