aherve
aherve

Reputation: 4070

algolia best practices : new index or tags?

I'v successfully setup an algolia search engine on my web page. My backend syncs public data to algolia, and the searchbar works just fine.

Now I want to setup the same for my admin application. Unlike the public application, this app should be able to recover secret data from algolia.

So far, I can think about two ways of doing this:

  1. For each document, store both a "public" version (with a "public" tag) and an admin version (tagged "admin", and with additional fields). Custom api keys can then ensure that each app has access to the proper data.

OR

  1. Create a new index, perhaps my_admin_collection_index, duplicate the settings, and use it just like the my_collection_index from the admin app.

So in first version I search the same index, but with different tags; in the second version I search two different indices.

Is there some insights about how to choose between the two approaches ? I'd say it would be easier for me to duplicate documents and put some tags on them, but I can't really tell about the performances impact of such an approach.

Thanks !

Upvotes: 5

Views: 515

Answers (1)

redox
redox

Reputation: 2319

The first approach consisting in pushing all objects to a single index and tagging them with the permissions is the good way to go. Combining that approach with the Secured API keys allows you to easily scale while keeping a secure front-end implementation (embedding the key in the javascript code for instance).

Even if the Algolia engine supports an unlimited number of indices per application (I saw users with +700,000 indices), having too many indices may result in some indexing overheads & slowdown (especially on the mutualized plans where you're sharing the indexing CPUs with other customers).

Upvotes: 4

Related Questions