About this parameter
Creates replicas (copies) of an index.
Use replicas to create copies of your primary index with a different configuration (settings, synonyms, Rules). Replicas are typically used for:
- Alternative sorting strategies such as only re-ordering relevant results
- Multiple indices for example you might use one replica for ascending price and another for descending price
- A/B testing.
Since the replica’s data is the same as its primary index, it’s automatically synchronized with any updates to the primary. All indexing operations on a primary index (adding, updating, and deleting objects) are forwarded to its replicas.
A primary index can have as many replicas as you wish. However, a replica can only have one primary; in other words, two primary indices can’t have the same replica. Furthermore, a replica can’t have its own replicas (you can’t “chain” replicas).
primary parameter (the name of a replica’s primary index) is automatically added to a replica’s settings.
Each use of this parameter defines the complete set of replicas for an index. Adding replicas to the list will create a new replica index or overwrite an existing one. If the index:
- Doesn’t already exist, a new replica is created (containing the same data and settings).
- Already exists, only its data is overwritten. Its settings remain as they were. If you want the replica to have the same settings as the primary, copy the settings from the primary index to the replica index separately, or remove the existing replica index before using this method.
If you omit an existing replica from your list, it will no longer be synchronized and will revert to being a regular, independent index.
To delete a replica from your account, you must first detach the replica from its primary index by running
setSetting without listing the replica index you want to delete: you can then delete the index.
Settings replicas indices
1 2 3 4 5 6 $index->setSettings([ 'replicas' => [ 'name_of_replica_index1', 'name_of_replica_index2' ] ]);