Dynamic ordering based on formula

Hi All,

I am building a site for the promotion and dissemination of events. I want use AlgoliaSearch to improve the searches. The site I am building allows to promote events.

This allows the promoted events to appear among the first results as highlighted. This also allows AlgoliaSearch, but, I have the following scenario:

The site allows you to sponsor events per day, that is, you can select the month days in which you want the event to appear promoted in the search results (on top). For this scenario you would have to calculate if the promotion date for the event matches the current date, this event will appear in the first results.

Anyone know if this is possible with AlgoliaSearch? A reference for reading will helpfully.

Thanks in advance.

As a start, check out Query Rules, specifically the Hit Promotion component.

Haven’t had a chance to dive into the Query Rules feature myself, but from what I remember it was created for exactly this type of use case.

Hi there!

As @chad said, Query Rules would be a great solution for your problem, however we do not support conditions on dates for the moment so you can’t do something like “if event.date is today, then promote”.
This is a great use-case and we plan to add it in future versions of Query Rules.

In the meantime, you can implement this logic manually (promote visually an event if the date is today, and move it on top)
A solution would be to make 2 queries and merge the result: the first query to search all the matching event, and the second query to get the matching events with “date=today”. This second query will give you the events to promote and you can display it as you wish.

Thanks @chad and @jvenezia for your answers. I will follow your suggestions.

@jvenezia in case you want to make use of instantsearch.js as one of the results of these two queries?