Conditional facet exclusion

I am a total beginner with Algolia, so I am sorry if my question is somewhat stupid. I have been searching for hours now without result, so I am craving for any help you could provide.
I will try to make myself the clearest I can.


I have tutorials with different statuses (online, offline, work_in_progress etc) and a creator id in my index that I want to display.

I use algoliasearch helper JS in a rails environement without front framework.

What I would like to do

I would like to display every tutos except for the one that are with the status “work_in_progress”, unless the current user is the tutorial’s owner.

A typical if condition (in pseudo code, but should be in JS) would look like this :

if (status != 'work_in_progress')
    then display
else if (status == 'work_in_progress' && user_id !=
    then reject

What I have tried

I have tried to remove after the search the unwanted results, but it brokes my pagination.

I also tried to add multiples refinements, but the two condition are applied on all tutorials, so it prevents every tutorials that are not “work_in_progress” or not owned by the current user to be displayed.

I looked in Algolia query rules without success.

I know I should filter even before searching, with filters, refinement and so on, but I am unable to find what I am looking for.

Any help or documentation would be appreciated.

Hello developers1,

I ran into a similar issue where I wanted to refine my data by a facet right off the bat that the user could not change. Then when they searched, they only searched within a subset of the data.

For this, take a look into the documentation on algoliasearch helper’s Search Parameters > filters.

I did this using instantsearch.js’s filters.
This post was were I asked the question to be able to do this.

Hopefully this helps you.

1 Like