Guides / Sending and managing data / Format and structure your data

Choosing Between One or More Indices

Algolia lets you put all your records into a single index, or spread them across several indices. There’s no limit to how many indices you can have.

Multiple indices are useful when you have different kinds of data (e.g., movies and actors) or need different ranking strategies for the same data (e.g., most recent movies and highest rated movies).

How you organize your indices ultimately corresponds to how you want to search and display your records.

Imagine a website that has a search experience for movies, and another one for actors. You may want to retrieve the cast when searching for movies, or the movies they appear in when searching for actors, but you’re still searching for two different types of content. In this case, you’re better off with separate indices. It would let you configure each index independently, and tailor them to their specific content.

If you want a single experience, where you could search for anything, display movies and actors in the same results, and rank them together, then they would need to be in the same index.

Query Suggestions

There are other use cases for using several indices. For example, if you want to present popular queries with an autocomplete menu, you could leverage our Query Suggestions feature. In this case, you need two indices: one for your content, and one for the common queries.

Different sorting strategies

You also need to use separate indices when you want to let your users switch between different rankings. For example, with a search experience displaying products, you may want to allow users to sort by ascending or descending price. You can’t dynamically change the ranking of an Algolia index, but you can use replica indices. A replica is a special index which contains the same data, with different ranking strategy.

Replicas are ideal for providing different sorting options. All you need to do is offer a way for your end users to select a sorting option on your front end and dynamically switch to the right index.

Different environments

We recommend using separate indices for all your environments and generating new indices and API keys for each of them. This allows you not to skew your search analytics, avoids indexing accidents, and keeping each environment more secure.

For example, if you have three environments (development, staging, and production), you can create three indices: dev_products, staging_products, and prod_products. To minimize the impact of testing and staging on your operation count, we recommend that you use a subset of your data in non-production environments. For example, you can test your staging environment with only 10% of your records.

Did you find this page helpful?