InstantSearch - Search if one of the dates of an array is inside range of dates

Hi everybody,
I have in my index model, an array of events which contains a date (Unix timestamp) => each object has its array of events.

Example of one of my objects:

I have created with for the user to pick a range of dates :

The goal is to havce the user filter my results based on models which have at least 1 result in their events array that is inside the date range.

Is it possible? Is there a preferred method to do this ?

I have access to the two dates in unix timestamp from the date picker but I don’t know how to create a custom filter or widget and what would be the best way to do it?

Thanks in advance !


Hello @arnaud.tiret,

Are you using InstantSearch.js? If so, have you seen this guide about creating a calendar widget?


Hi Bobylito,
thanks for your response, the article is very interesting but did not apply to my case, as I don(t have an index of events, but of objects that all have events, and I want to show the objects even if there are no events in them.

Solution - For the record :
I found a solution by defining my events date (as timestamps) as a facet :

And I’m using helper (Algolia JS Helper) to filter on the results :
search.helper.setQueryParameter('filters', 'evenements.start < '+moment(end).unix()+' AND evenements.start > '+moment(start).unix()).search();

And it made the trick ! :smile: