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
require "algolia"
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
response = client.save_synonyms(
"ALGOLIA_INDEX_NAME",
[
Algolia::Search::SynonymHit.new(object_id: "id1", type: "synonym", synonyms: ["car", "vehicule", "auto"]),
Algolia::Search::SynonymHit.new(
object_id: "id2",
type: "onewaysynonym",
input: "iphone",
synonyms: ["ephone", "aphone", "yphone"]
)
],
true,
true
)
Did you find this page helpful?