🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
API client / Methods / Synonyms
Required API Key: any key with the editSettings ACL
Method signature
$index->replaceAllSynonyms(array synonyms);
$index->replaceAllSynonyms(array synonyms, [
  'forwardToReplicas' => boolean
]);

We released a new version of the PHP API client in public beta. Read the beta documentation for more information.

We released a new version of the JavaScript API client in public beta. Read the beta documentation for more information.

We released a new version of the Java API client in public beta. Read the beta documentation for more information.

You’re currently reading the JavaScript API client v4 documentation. Check the migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.

You’re currently reading the Ruby API client v2 documentation. Check the migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.

About this method

Push a new set of synonyms and erase all previous ones.

This method, like replaceAllObjects, guarantees zero downtime.

All existing synonyms are deleted and replaced with the new ones, in a single, atomic operation.

Examples

Read the Algolia CLI documentation for more information.

Replace all synonyms

1
2
3
4
5
6
7
8
9
10
11
12
$client = Algolia\AlgoliaSearch\SearchClient::create(
  'YourApplicationID',
  'YourWriteAPIKey'
);

$synonyms = /* Fetch your synonyms */;

$index = $client->initIndex('your_index_name');
$index->replaceAllSynonyms($synonyms);

// Or if you want to also replace synonyms on replicas
$index->replaceAllSynonyms($synonyms, ['forwardToReplicas' => true]);

Parameters

Parameter Description
synonyms
type: list
Required

A list of synonyms

forwardToReplicas
type: boolean
default: false
Optional

Also replace synonyms on replicas

requestOptions
type: key/value mapping
default: No request options
Optional

A mapping of requestOptions to send along with the request.

Response

This method doesn't return a response.

Did you find this page helpful?