Filtering results by role

Hi, I’ve recently setup an index and integrated it with a react web app using react instantsearch - and its great :+1:t4:

I’ve been investigating (query rules etc.) the possibility of filtering results returned to the user - based on a user’s role.

High level scenario
- Index
○ Add or update an JOSN item to the index with a “Role” attribute eg {“Role”:[“group1”, “group2”, “group3”]} or {“Role”:[“public”]}
- User Searches for an item
○ React container retrieves a “Role” attribute from a user profile object eg. {“Role”:[“group2”]} and makes this available to pass to search
○ InstantSearch.js - as part of the search processing would;
- Allow appropriate results with a “Role” of “Public”
- Allow appropriate results with a “Role” of those in my user profile eg. “group2”
- Remove results with a “Role” of those not in my user profile eg. “group1”, “group3”

Looking for guidance or feedback.

Thanks, Tama

Hey Tama,

To understand it correctly, is it something like this you want to make?

Or am I missing what your question is? :slight_smile:

1 Like

Hey Haroen, thank you very much :pray:t4: After stepping thru the code and focusing on the Virtual Refinements I was able to get a basic virtual refinement working for my use case - basic security trimming or search results.

1 Like