A lot of index or a lot more record

Hi I have a app that users can follow and gain followers. Think of it like Instagram following and followers concept.

If a user wants to search for a follower, in Algolia will it be preferable to have an index of all user id and inside each index a record for all his/her followers. or will it be preferable to have just a follower index and inside there will be a map with the key as the user id and the value as an array of maps containing all the followers info.

Let me know if you need further explanation.

Thanks for the help.

The most Algolia way to do so would be to build a single user index with objects like:

{user_id: 1, following: [user_id, user_id]}

Then when a user wants to search for their followers, you can use a filter like:

{filters: "following=1"}

Then you could also use secured api keys so you can only search your followers and not search the followers of other users: https://www.algolia.com/doc/guides/security/api-keys/#secured-api-keys

2 Likes