Filter Results Based on Days Since Original Post

Hey! I’m hoping someone can offer a relatively simple and streamlined solution for what I’m trying to accomplish. Basically, I need Algolia to only return results for records that were originally posted within seven days of being uploaded. I’m not sure if this is the best way to accomplish this-- or if I need some sort of automated script to simply delete those records. I would prefer to not have to delete them though. Any assistance would be greatly appreciated. Thank you!

Hi there, if each record has a numeric timestamp attribute for when it was created, then you might be able to use numeric filters and template literals to avoid displaying these older records.

Rough example:

 let weekAgo = Date.now() - 604800000;

 index.search('query', {
     filters: `timestamp_added > ${weekAgo}`
 }).then(({ hits }) => {
     console.log(hits);
 });
1 Like

Thank you for the swift response. I’ll give this a try!