[InstantSearch] Add numeric refinement @ first query

Hi there!

I am working on my first project with algolia. RIght now I have the following issue: I try to pre-filter my results by a Unix time integer so only not expired contents get displayed:

var d = new Date();

var search = instantsearch({
  appId: 'XXX',
  apiKey: '2XXXXXXXXXXf4',
  indexName: 'contents_production',
  urlSync: true,
  urlSync: {},
  facetsRefinements: {
  expires: ['<'+d.getTime()]

This is how I thought it may work when reading the doc, but I was not able to get it running. Is this only for facets? How do I achieve what I need? I am trying to avoid the cronjob that deletes expired entries from algolia.

Thank you for the help!


Hi @simon.stappen! In order to deal with numeric filters such as date, you should use numericRefinements instead of facetsRefinements. A numeric refinement will give you the capability to do operations such as > or <= etc. Let me know if you still have questions :slight_smile:

1 Like

and the Query works as a string? e.g.:


Thanks for your help! :slight_smile:

You can do something like numericRefinements: {aNumAttr: {'>=': [100], '<=': [200]}} or just numericRefinements: {aNumAttr: {'<': [100]}}