Guides / Managing results / Refine results / Sorting results

Forward Settings to Replicas

It’s common to have several replica indices that differ from their primary index by a single setting, such as the sorting strategy. Products in an e-commerce store are a good example. You may have a primary index sorted by ascending price, and one or more replicas that sort products by descending price, descending popularity, descending rating, etc.

However, despite these different sorting settings, you may still want to propagate other settings from a primary index to its replica(s). For example, if you decide to change the searchableAttributes setting, you probably want it to apply to all indices (primary as well as replicas).

The forwardToReplicas parameter allows you to forward new settings to replicas. From there, it’s easy to change only the settings that need to be different and keep all others in sync.


Back to our example. Let’s say we have a primary index called products and a products_price_desc replica. Both indices have the same data and settings, apart from the ranking setting.

Now imagine we want to change the searchableAttributes setting to include a new description attribute for all indices, primary and replicas. We can achieve this by leveraging the forwardToReplicas parameter.

Using the API

The setSettings method, along with all synonyms and Rules methods, have a forwardToReplicas parameter. By default, forwardToReplicas is set to false, so any setting, synonym, or Rule change only applies to the target index. By setting it to true, you can forward these changes to all the replicas belonging to the index you target.

$forwardToReplicas = true;

    'searchableAttributes' => ['name', 'description'],

Settings are only forwarded to existing replicas. If you want to forward settings and create a replica, you first have to create the replica, and forward the settings after. These must be separate operations.

Using the Dashboard

Whenever you make a settings change from the Algolia dashboard, we prompt you to review the change before saving. In the confirmation modal, you have an option to Copy these settings to other indices and/or replicas. From there, you can forward the changes to a subset or all replicas.

Whenever you forward settings changes to replicas, you completely replace the previous setting on the replica. For example, if you change the ranking formula on the primary index to include a sort on an inventory attribute, and then choose to copy the updated ranking setting to all replicas, you overwrite any previously set sorts on other attributes on the replicas.

When altering the ranking formula on indices with replicas, we recommend doing it on an a per index basis.

While customRanking is part of the ranking formula, it is its own separate setting as well. You can safely alter custom ranking and forward the change to your replicas without worrying about overwriting the entire ranking formula.

Overwriting settings isn’t something you need to worry about in most cases, since you usually want most settings to be the same between replicas. Notable exceptions include ranking and typoTolerance.

The dashboard also lets you forward Synonyms and Rules: When adding, editing, or deleting a Synonym or a Rule, check the Forward to replica indices checkbox before you click the Save button.

Did you find this page helpful?