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
15
16
17
18
19
20
21
22
23
24
25
26
using Algolia.Search.Clients;
using Algolia.Search.Models.Search;
var client = new SearchClient(new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
var response = await client.SaveSynonymsAsync(
"ALGOLIA_INDEX_NAME",
new List<SynonymHit>
{
new SynonymHit
{
ObjectID = "id1",
Type = Enum.Parse<SynonymType>("Synonym"),
Synonyms = new List<string> { "car", "vehicule", "auto" },
},
new SynonymHit
{
ObjectID = "id2",
Type = Enum.Parse<SynonymType>("Onewaysynonym"),
Input = "iphone",
Synonyms = new List<string> { "ephone", "aphone", "yphone" },
},
},
true,
true
);
Did you find this page helpful?