I work in Search and have seen following problem appear in different forms. There are many users in an enterprise; they have ability to create records. Each user has variable level of access to some or all of the records of the enterprise; and the record creator can manage access to the record.
How do we design a search feature for these records?
Index the records with some information about the access level. This has many limitations. It only works if there are limited possibilities in the access permutations, which is generally not the case. Imagine files being shared on Google drive. If there are m users, then for each record there are 2^m possibilities of read permission (i.e., does a user has read access to the record or not). And if there are n documents, then total permission possibilities explode to n * 2^m (assuming my probability calculation is correct, in any case the permission info permutations are beyond manageable to keep with record).
Index all the records and execute the query on the documents, and later filter the results based on user's permissions. This approach works for complex permission models however the downside is that we are searching ton of extra documents and later discarding them.
Index documents separately for each user (as we are sure that the user as access to them). Track each record shared to the user, so that only these limited set of documents are searched through for each query. This avoid the issue with #2; but if a lot of sharing is being done, then it will not scale well.
I am hoping that there is a better way to design this problem. Google Drive must be doing something more intelligent than what I am thinking above.