editSettings
This operation is subject to indexing rate limits.
Usage
// Initialize the client
var client = new SearchClient(new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.SaveSynonymsAsync(
"<YOUR_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
);
// print the response
Console.WriteLine(response);
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.saveSynonyms(
indexName: "<YOUR_INDEX_NAME>",
synonymHit: [
SynonymHit(
objectID: "id1",
type: SynonymType.fromJson("synonym"),
synonyms: [
"car",
"vehicule",
"auto",
],
),
SynonymHit(
objectID: "id2",
type: SynonymType.fromJson("onewaysynonym"),
input: "iphone",
synonyms: [
"ephone",
"aphone",
"yphone",
],
),
],
forwardToReplicas: true,
replaceExistingSynonyms: true,
);
// print the response
print(response);
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.SaveSynonyms(client.NewApiSaveSynonymsRequest(
"<YOUR_INDEX_NAME>",
[]search.SynonymHit{*search.NewEmptySynonymHit().SetObjectID("id1").SetType(search.SynonymType("synonym")).SetSynonyms(
[]string{"car", "vehicle", "auto"}), *search.NewEmptySynonymHit().SetObjectID("id2").SetType(search.SynonymType("onewaysynonym")).SetInput("iphone").SetSynonyms(
[]string{"ephone", "aphone", "yphone"})}).WithForwardToReplicas(true).WithReplaceExistingSynonyms(true))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
// Call the API
UpdatedAtResponse response = client.saveSynonyms(
"<YOUR_INDEX_NAME>",
Arrays.asList(
new SynonymHit()
.setObjectID("id1")
.setType(SynonymType.SYNONYM)
.setSynonyms(Arrays.asList("car", "vehicule", "auto")),
new SynonymHit()
.setObjectID("id2")
.setType(SynonymType.ONEWAYSYNONYM)
.setInput("iphone")
.setSynonyms(Arrays.asList("ephone", "aphone", "yphone"))
),
true,
true
);
// print the response
System.out.println(response);
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
// Call the API
const response = await client.saveSynonyms({
indexName: '<YOUR_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,
});
// print the response
console.log(response);
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")
// Call the API
var response =
client.saveSynonyms(
indexName = "<YOUR_INDEX_NAME>",
synonymHit =
listOf(
SynonymHit(
objectID = "id1",
type = SynonymType.entries.first { it.value == "synonym" },
synonyms = listOf("car", "vehicule", "auto"),
),
SynonymHit(
objectID = "id2",
type = SynonymType.entries.first { it.value == "onewaysynonym" },
input = "iphone",
synonyms = listOf("ephone", "aphone", "yphone"),
),
),
forwardToReplicas = true,
replaceExistingSynonyms = true,
)
// print the response
println(response)
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
// Call the API
$response = $client->saveSynonyms(
'<YOUR_INDEX_NAME>',
[
['objectID' => 'id1',
'type' => 'synonym',
'synonyms' => [
'car',
'vehicule',
'auto',
],
],
['objectID' => 'id2',
'type' => 'onewaysynonym',
'input' => 'iphone',
'synonyms' => [
'ephone',
'aphone',
'yphone',
],
],
],
true,
true,
);
// print the response
var_dump($response);
# Initialize the client
# In an asynchronous context, you can use SearchClient instead, which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
# Call the API
response = client.save_synonyms(
index_name="<YOUR_INDEX_NAME>",
synonym_hit=[
{
"objectID": "id1",
"type": "synonym",
"synonyms": [
"car",
"vehicule",
"auto",
],
},
{
"objectID": "id2",
"type": "onewaysynonym",
"input": "iphone",
"synonyms": [
"ephone",
"aphone",
"yphone",
],
},
],
forward_to_replicas=True,
replace_existing_synonyms=True,
)
# print the response
print(response)
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
# Call the API
response = client.save_synonyms(
"<YOUR_INDEX_NAME>",
[
Algolia::Search::SynonymHit.new(algolia_object_id: "id1", type: "synonym", synonyms: ["car", "vehicule", "auto"]),
Algolia::Search::SynonymHit.new(
algolia_object_id: "id2",
type: "onewaysynonym",
input: "iphone",
synonyms: ["ephone", "aphone", "yphone"]
)
],
true,
true
)
# print the response
puts(response)
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.saveSynonyms(
indexName = "<YOUR_INDEX_NAME>",
synonymHit = Seq(
SynonymHit(
objectID = "id1",
`type` = SynonymType.withName("synonym"),
synonyms = Some(Seq("car", "vehicule", "auto"))
),
SynonymHit(
objectID = "id2",
`type` = SynonymType.withName("onewaysynonym"),
input = Some("iphone"),
synonyms = Some(Seq("ephone", "aphone", "yphone"))
)
),
forwardToReplicas = Some(true),
replaceExistingSynonyms = Some(true)
),
Duration(100, "sec")
)
// print the response
println(response)
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.saveSynonyms(
indexName: "<YOUR_INDEX_NAME>",
synonymHit: [
SynonymHit(objectID: "id1", type: SynonymType.synonym, synonyms: ["car", "vehicule", "auto"]),
SynonymHit(
objectID: "id2",
type: SynonymType.onewaysynonym,
synonyms: ["ephone", "aphone", "yphone"],
input: "iphone"
),
],
forwardToReplicas: true,
replaceExistingSynonyms: true
)
// print the response
print(response)
See the full API reference
For more details about input parameters
and response fields.