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 for sorting products by descending price, descending popularity, descending rating, and so on.

Yet, besides these different settings, you may still need to propagate other settings from primary index to their replicas. For example, if you decide to change the typo tolerance setting, you may 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.

Example

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 typoTolerance from true to "strict" for all indices, primary and replicas. We can achieve that by leveraging the forwardToReplicas parameter.

Using the API

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

1
2
3
4
5
6
7
8
$forwardToReplicas = true;

$index->setSettings(
  [
    "typoTolerance": "strict"
  ],
  $forwardToReplicas
);

The forwardToReplicas parameter is also available with all synonyms and Query Rules methods. When you add, edit, or delete a synonym or a rule on an index, you can forward it to its replicas as well.

Using the Dashboard

The Algolia dashboard only allows you to forward to replicas when setting up synonyms and Query Rules. For other settings, you need to use the API.

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?