Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

algolia best practices : new index or tags?

Tags:

algolia

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 !

like image 468
aherve Avatar asked May 03 '16 15:05

aherve


People also ask

Why you should create multiple indexes?

Using more indexes to increase performance The disks will spend less time seeking when accessing the source type in question. If you have access to multiple storage devices, placing indexes on different devices can help increase the performance even more by taking advantage of different hardware for different queries.

Does Algolia charge for indexing?

Algolia doesn't charge for search operations, only for write operations. We charge for all operations which are either indexing or search operations.

What is Algolia index?

An index is the place where the data used by a search engine is stored. It is the equivalent for search of what a “table” is for a database. Unlike a database table, an index is optimized for search operations.


1 Answers

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).

like image 166
redox Avatar answered Oct 14 '22 03:10

redox