How do I restrict searches to only return results from a limited subset of documents in the index (e.g. for privacy reasons)?

Otis Gospodnetic

The QueryFilter class is designed precisely for such cases.

Another way of doing it is the folowing:
Just before calling IndexSearcher.search() add a clause to the query to exclude documents in categories not permitted for this search.

The query parser always returns a BooleanQuery, so you can simply add required or prohibited terms to restrict access to documents that have (or don't have) these terms.

If you are restricting access with a prohibited term, and someone tries to require that term, then the prohibited restriction wins.
If you are restricting access with a required term, and they try prohibiting that term, then they will get no documents in their search result.

As for deciding whether to use required or prohibited terms, if possible, you should choose the method that names the less frequent term. That will make queries faster.