简体   繁体   中英

How to Automatically update elasticsearch document?

I'm building a backend for a basic crud app. 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. 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.

You can use upsert scripts to achieve this. Here is documentation -

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. 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. Then you don't have a second process, which might fail on its own etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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