I am building a messaging system with Cloudant, comprised of 'message' and 'membership' documents:
message documents:
{"_id":"1","type"="message","group":"a","text":"this is message 1"},
{"_id":"2","type"="message","group":"a","text":"this is message 2"},
{"_id":"3","type"="message","group":"b","text":"this is message 3"},
...
membership documents:
{"_id":"a","type"="membership","user":"joe","group":"a"},
{"_id":"b","type"="membership","user":"bob","group":"a"},
{"_id":"c","type"="membership","user":"bob","group":"b"},
...
Each message is associated with one group. A user may have a membership in hundreds of different groups.
I would like to perform full text searches on the message text, on behalf of a particular user. The application requires that users must not see messages from groups that they are not members of.
how can I do a full text search that returns only messages from groups that a particular user belongs to?