简体   繁体   English

"如何自动更新弹性搜索文档?"

[英]How to Automatically update elasticsearch document?

I'm building a backend for a basic crud app.我正在为一个基本的 crud 应用程序构建一个后端。 I have a model for a title document with a field "status" which can be either "ingested, expiring and expired".我有一个标题文档模型,其中包含一个“状态”字段,可以是“摄取、过期和过期”。 The logic for an expiring document is when the expiry date - current date is less than 30 days.到期文档的逻辑是到期日期 - 当前日期小于 30 天。 How do i automatically update the document store when a the expiry date has elapsed?过期日期过后如何自动更新文档存储?

"

Assuming you want to automate this process after specific period, I would suggest to create a Cron that runs daily/monthly basis to update ES docs. 假设您希望在特定时间段后自动执行此过程,我建议您创建一个每日/每月运行的Cron来更新ES文档。

You can use upsert scripts to achieve this. 您可以使用upsert脚本来实现此目的。 Here is documentation - 这是文档 -

https://www.elastic.co/guide/en/elasticsearch/guide/current/partial-updates.html https://www.elastic.co/guide/en/elasticsearch/guide/current/partial-updates.html

Hope this helps 希望这可以帮助

There is no automatic way in Elasticsearch to do that. Elasticsearch中没有自动方式来做到这一点。 While you could create a separate process to change that flag, it might be easier to implement your logic "expiry date - current date is less than 30 days" within your application. 虽然您可以创建一个单独的流程来更改该标志,但在您的应用程序中实现逻辑“到期日期 - 当前日期少于30天”可能更容易。 Then you don't have a second process, which might fail on its own etc. 那么你没有第二个进程,它可能会自行失败等。

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

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