Forward Settings to Replicas
On this page
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 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 this by leveraging the forwardToReplicas
parameter.
Using the API
The setSettings method, along with all synonyms and Query 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.
1
2
3
4
5
6
7
8
$forwardToReplicas = true;
$index->setSettings(
[
"typoTolerance": "strict"
],
$forwardToReplicas
);
Using the Dashboard
The Algolia dashboard only allows forwarding 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.