Score:1

How to create a search api facet for filtering user access

pk flag

I'm trying to figure out how to create a search api facet, that will filter results based on user access. By default, I'm bypassing access check hence showing all the nodes. I need to add a checkbox, which will filter results by access for current user (showing only already purchased items). One approach could be perhaps indexing all accessible nodes per user (about 300 nodes and 4000 users at the moment) similarly to flag_search_api or another and likely more elegant solution, adding access check to query if the access checkbox is selected. Does anyone have any idea if the latter would work and how to actually implement it?

Thanks.

ve flag
unfortunatley I don't know, but if you are only talking about 300 nodes, it should not much of a performance hit to implement some custom query. You could also try to simply impelment it as 100% custom controller and not mess with the standard search
pk flag
I don't mind creating a custom module but looking for some hints.
ve flag
sure, [this how-to](https://www.drupal.org/docs/creating-custom-modules/step-by-step-tutorial-hello-world) is a good starting point
pk flag
Thanks, but I was hoping to get some hint related to facets particularly. I can create custom modules in general.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.