Hello Algolia Team and Community!
I am new to Algolia and have been reading through the documentation but am still unsure the best way to structure my data. The data I would like to index is structured as follows:
(- denotes sub-document and document attributes are listed after the : )
Group 1: group_id, members (array of uids), private (true or false)
-Post 1: group_id
-Post 2: group_id
Group 2: group_id, members (array of uids), private (true or false)
-Post 3: group_id
-Post 4: group_id
User 1: uid
User 2: uid
I would like to be able to use a single search form to search for groups, users, and posts if at all possible. However, I am able to separate it out if necessary.
I want the behavior to work as follows: If a user is a member of a group that is private, the group and posts will show up in a search. If a group is public, the group and its posts will show up in a search.
*Note: It is not possible to copy the members of a group to each post. The members array will be updated dynamically and new posts will also be added to each group.
My data is currently stored in Firebase’s Cloud Firestore and I’m using a combination of security rules on sub collections and documents to allow reads and writes as well as cloud functions to check group membership. The only solution I’ve come up with so far is to separate the searching of posts and groups. I can search for groups using filters and a secured API key, but then would have to do a search for posts on the backend and manually filter out the ones a user does not have access to.
Any suggestions and recommendations would be extremely helpful! I understand that this is a bit of an atypical use case, but I appreciate any insight. Thanks!