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:
image

I have created with http://www.daterangepicker.com/ for the user to pick a range of dates :
image

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 !

Best

Hello @arnaud.tiret,

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

Cheers,

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 :
image

And I’m using helper (https://community.algolia.com/algoliasearch-helper-js/) 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: