I want to implement a dropdown menu to filter sear...
# community-help
c
I want to implement a dropdown menu to filter searches for a certain date range. E.g., last day, last month etc. I am using typesense adapter and React InstantSearch Hooks. How do I accomplish this? I have managed to sort my results but I'm stuck at filtering them for those criteria
d
Do you need facet counts for each option?
c
I don't think, so I basically only want a dropdown with those 4 options to choose from. A user can select one and the search gets filtered for the selected criteria. @Dima
j
You’d need to add a field to every document with the exact value that you want to show users to filter on
For eg, if you have a timestamp field that stores the date in Unix timestamp and you want to show the user “2022-2023”, you’d need to have a new field with that exact value “2022-2023" that you compute at indexing time, and then in the refinementList mention that field as the attribute
c
So its not possible to dynamically filter based on the timestamp and the current time?
j
Not with the standard instantsearch widgets
You’d have to build a custom widget
c
Yeah thats what im actually trying to do. I'm using React InstantSearch Hooks currently
j
May be you could adapt this widget to do relative dates: https://github.com/algolia/react-instantsearch-widget-date-range-picker