To effectively manage this issue, consolidate all records (across multiple users) into a unified index and assign them unique user IDs as tags.
{ "objectID": 1, ....., "_tags": ["user_21"] }
{ "objectID": 2, ....., "_tags": ["user_21"] }
{ "objectID": 3, ....., "_tags": ["user_42"] }
During search queries, utilize the Secured API Keys to limit the search results to a specific user ID. By implementing this secure approach in your JavaScript code, you can ensure that users only access the data they are authorized to view.
Within your backend:
// if the current user ID is 42
public_key = Algolia.generate_secured_api_key('<SearchOnlyAPIKeyKeptPrivate>', {filters: 'user_42'})
Within your frontend:
var client = algoliasearch("APPID", '<PublicApiKeyGeneratedForUser42>');
index.search('.....');
For further information on API keys, particularly Secured API Keys, refer to: