API Reference / API Parameters / replicas
Feb. 26, 2019
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, exact copies of an index.

The purpose of replicas is to create variants of your main index, where the data is the same and the variance is in the configuration (settings, synonyms, query rules).

The data in a replica is automatically synchronized with its primary index, which means that all indexing operations on an index (adding, updating, and deleting objects) are forwarded to its replica(s).

This is used mainly for:

The counterpart of replica, the primary parameter, is automatically added to a replica’s settings. primary stores the name of a replica’s primary index. The legacy name of the primary parameter is master.

Usage notes:

  • Adding Replicas:

    • Each use of this setting defines the full set of replicas for an index. Any index omitted from the list is no longer a replica.

    • Adding replicas to the list will either create a new replica index or overwrite an existing one.

      • If the index does not already exist on your account, a new index is created containing the same exact data and settings. For this reason, you’ll need to make sure you have enough space on your account before creating a new replica.

      • If the index already exists on your server, then only its data is overwritten; its settings remain as they were before the method call. If you want the replica to have the same exact settings, you can either remove the replica before running this method, or resend the primary index’s full settings to the existing replica.

  • Removing Replicas:.

    • If you omit an existing replica from your list, it will no longer be a replica and will revert to being a normal, independent index (continuing, for example, to take up space on your Account). All synchronization between it and its primary will be lost. You can always put it back on the list later.

    • If you wish to delete a replica from your Account, you must first rerun this setting without listing the index you want to delete. That will detach the index. At that point, you can delete the index.

  • A primary index can have as many replicas as needed. However, a replica can only have one primary; in other words, two primary indices cannot have the same replica. Furthermore, a replica cannot have its own replicas (i.e. you cannot “chain” replicas).

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?