Filter out `is_active: false` results from index

So I have this index, with a lot of entries.

I just added a is_active: boolean attribute to it.

What I need is to filter out the entries with is_active: false, without removing them from the index.

I thought it would be piece of cake to parameterize in the options, but surprisingly it is not and I’m now struggling.

Can someone help me setting this up?

My searches took me to understand that:

  • filter would happen at query time and not indexing time (which is totally fine to me)
  • so I’m guessing this should be set somewhere in the client options (using client-side JS algoliasearch)

Something like:

const client = algoliasearch(algolia_app_id, algolia_search_api_key);
const index = client.initIndex('my_index', {...options}) // <- THERE ?
autocomplete.sources.hits(index, {hitsPerPage: 5, queryType: 'prefixAll', ...options}) // <- OR THERE? 

The docs seem to mention that it is related to faceting, but I really don’t understand anything there. :unamused:

Or it would have something to do with rules there, which is not much better? :unamused:

Anyway, I’m lost, help much appreciated! Anyone encountered this situation before?


Hi @augustin.riedinger,

I believe you are using Algolia instantsearch.

I have created a sandbox that shows how to use filters with the configure widget. You’ll see on line 12 in app.js where the filter is used.

Of course, you’ll need to change the attribute name from brand to ‘is_active’ and the value to false for your filter.