Sep 20, 2024
Create or replace synonyms
If a synonym with the objectID
doesn’t exist, Algolia adds a new one.
Otherwise, existing synonyms are replaced.
Usage
Required ACL:
editSettings
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { algoliasearch } from 'algoliasearch';
//
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
const response = await client.saveSynonyms({
indexName: 'ALGOLIA_INDEX_NAME',
synonymHit: [
{ objectID: 'id1', type: 'synonym', synonyms: ['car', 'vehicule', 'auto'] },
{ objectID: 'id2', type: 'onewaysynonym', input: 'iphone', synonyms: ['ephone', 'aphone', 'yphone'] },
],
forwardToReplicas: true,
replaceExistingSynonyms: true,
});
Did you find this page helpful?