Services Plugins FAQs

Date Filter for Algolia Query

I’m trying to filter results in my Algolia query based on the date. In Bubble, I save each record with a UNIX timestamp that is uploaded to Algolia. Basically, what I need is to ensure that when someone runs a search on my Bubble app, Algolia only returns records uploaded within the past week. I tried using the following filter in the Simple Search plugin filter input:

let weekAgo = Date.now() - 604800000;

index.search(‘query’, {
filters: timestamp > ${weekAgo}
}).then(({ hits }) => {
console.log(hits);
});

However, no results are returned. I have index set up properly as an attribute available for faceting as well. Any advice on how to get this working would be greatly appreciated. Thank you in advance!

@levon Is it possible to get some assistance with this? I’m just trying to understand how the JavaScript should be formatted in the SimpleSearch plugin to filter by a past date.

Hey @themarshall, thank you for your patience and thank you for your message.

To investigate your particular use case of the plugin and to understand if the search for the ‘past week’ can be performed, it is needed some more time.
Allow me to check it with the developer team and come with feedback asap🙏.

As soon as there will be an update I will leave a message in this thread.

Thank you for understanding.

Have a great rest of the day!

Hi @themarshall, thank you for you patience.

After checking with the Dev team regarding the filter that will do the search only in the last week entries, I have some good news.
Please see the screenshot below and see how you can set the filter inside the Algoria element.

Besides that, please make sure you have the correct Unix timestamps value, inside the Algoria so the plugin will function as designed

Hope this helps. Let me know if there is anything else we can assist you with. :slightly_smiling_face:
Have a great weekend ahead!

1 Like

This worked perfectly. Thank you for your assistance.

2 Likes