Drupal - Building a search View that respects access control

For the Search Views module there's an option that enables further access checks on indexed entities that will enable your Taxonomy Access Control permission check.

You'll find in the Views UI under Advanced > Query settings on via the Settings link. It is enabled via the Additional access checks on result entities checkbox. As a caveat, this option will make result counts, pagination, and other search result details behave oddly since permission checks can't be made at index time.


I've gotten this to work, but it was not exactly straightforward, mainly because there wasn't a clear way to find out what to filter for in the view. Big thanks to @Shawn Conn for the idea of contacting Jon Pugh, who wrote the comment in the help page, and Jon Pugh for answering me quickly. He didn't give me the answer, but made me feel more confident that if I kept working on what I was working on, there would be some likelihood of success.

Step One: Make sure node access info is being indexed

Make sure Node Access is being indexed

Step Two: Make the field available to views:

enter image description here

Step Three: In Solr, open your core, and in the Schema Browser find the access field:enter image description here

Step Four: Click on that field, Load Term Info, and see what access term data Solr is getting:

enter image description here

Step Five: In your view, enable a filter on the node access field, and filter using the value(s) you found in step four:

enter image description here

Further Notes

Filtering this way causes the search results counts and facet counts/facets available to all give the correct information. There is another option as in Shawn Conn's answer that will filter the results for access after the query has already been made. This filters the list separately from providing results to the facets and search information blocks, etc, which causes them to provide incorrect results.