🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
API Reference / API Parameters / replicas
Type: list of strings
Engine default: [] (no replicas)
Formerly: slaves
Parameter syntax
'replicas' => [
  'replica_index1',
  'replica_index2',
  ...
]

Can be used in these methods:

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:

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).

The primary parameter (the name of a replica’s primary index) is automatically added to a replica’s settings.

Usage notes

Adding replicas

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.

Removing replicas

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.

Examples

Settings replicas indices

1
2
3
4
5
6
$index->setSettings([
  'replicas' => [
    'name_of_replica_index1',
    'name_of_replica_index2'
  ]
]);
Did you find this page helpful?