editSettings
This method, like replaceAllObjects, guarantees zero downtime.
All existing synonyms are deleted and replaced with the new ones, in a single, atomic operation.
Examples
SearchClient client = new SearchClient("YourApplicationID", "YourWriteAPIKey");
SearchIndex index = client.InitIndex("INDEX_NAME");
List<Synonym> synonyms = /* Fetch your synonyms */
index.ReplaceAllSynonyms(synonyms);
// Or if you want to also replace synonyms on replicas
index.ReplaceAllSynonyms(synonyms, forwardToReplicas: true);
// Asynchronous
await index.ReplaceAllSynonymsAsync(synonyms, forwardToReplicas: true);
package main
import (
"github.com/algolia/algoliasearch-client-go/v3/algolia/search"
)
func main() {
client := search.NewClient("YourApplicationID", "YourAdminKey")
index := client.InitIndex("INDEX_NAME")
synonyms := []search.Synonym{ /* Fetch your synonyms */ }
res, err := index.ReplaceAllSynonyms(synonyms)
}
SearchClient client =
DefaultSearchClient.create("YourApplicationID", "YourWriteAPIKey");
SearchIndex index = client.initIndex("INDEX_NAME");
List<Synonym> synonyms = /* Fetch your synonyms */
index.replaceAllSynonyms(synonyms);
// Or if you want to also replace synonyms on replicas
index.replaceAllSynonyms(synonyms, true);
// Async
index.replaceAllSynonymsAsync(synonyms);
index.replaceAllSynonymsAsync(synonyms, true);
const client = algoliasearch('YourApplicationID', 'YourWriteAPIKey');
const synonyms = [/* Fetch your synonyms */];
const index = client.initIndex('INDEX_NAME');
index.replaceAllSynonyms(synonyms).then(() => {
// done
});
// Or if you want to also replace synonyms on replicas
index.replaceAllSynonyms(synonyms, { forwardToReplicas: true }).then(() => {
// done
});
// Fetch your synonyms
val synonyms = listOf<Synonym>()
index.replaceAllSynonyms(synonyms, forwardToReplicas = true)
$client = Algolia\AlgoliaSearch\SearchClient::create(
'YourApplicationID',
'YourWriteAPIKey'
);
$synonyms = /* Fetch your synonyms */;
$index = $client->initIndex('INDEX_NAME');
$index->replaceAllSynonyms($synonyms);
// Or if you want to also replace synonyms on replicas
$index->replaceAllSynonyms($synonyms, ['forwardToReplicas' => true]);
client = SearchClient.create('YourApplicationID', 'YourWriteAPIKey')
synonyms = [] # Fetch your synonyms
index = client.init_index('INDEX_NAME')
index.replace_all_synonyms(synonyms)
# Or if you want to also replace synonyms on replicas
index.replace_all_synonyms(synonyms, {'forwardToReplicas': True})
client = Algolia::Search::Client.create('YourApplicationID', 'YourWriteAPIKey')
synonyms = [] # Fetch your synonyms
index = client.init_index('INDEX_NAME')
index.replace_all_synonyms(synonyms)
# Or if you want to also replace synonyms on replicas
index.replace_all_synonyms(synonyms, { forwardToReplicas: true })
let client = SearchClient(appID: "YourApplicationID", apiKey: "YourWriteAPIKey")
let index = client.index(withName: "INDEX_NAME")
let synonyms: [Synonym] = [/* Fetch your synonyms */]
index.replaceAllSynonyms(with: synonyms,
forwardToReplicas: true) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}
Parameters
A list of synonyms
Also replace synonyms on replicas
A mapping of request options to send along with the request.