algoliasearch-client-javascript icon indicating copy to clipboard operation
algoliasearch-client-javascript copied to clipboard

delete objects/records by date

Open mkarsene opened this issue 4 years ago • 1 comments

Hi, I am a newbie. Thus I apologize if this is obvious. What is the best way (and how) can I delete records older than the current date? Say I have an index of events. But I only want to show events in the future or that that are currently happening. Each event has a timestamp attribute. How do I make sure to always delete events that have expired? Does algolia provide such a service? or do I have to run a cron job everyday that gets all records and deletes the older ones? Isn't this costly?

mkarsene avatar Feb 27 '21 23:02 mkarsene

you can run the "deleteBy" function periodically with a filter that has the timestamps before today, filters: "date <" + Date.now() / 1000 (or similar).

See the documentation here: https://www.algolia.com/doc/api-reference/api-methods/delete-by/?client=javascript

Haroenv avatar Mar 01 '21 13:03 Haroenv