Skip to content

Commit 2fba5e6

Browse files
committed
Use clearExisting for rules and synonyms
1 parent c6c4fea commit 2fba5e6

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/commonMain/kotlin/com/algolia/search/endpoint/EndpointSynonym.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ public interface EndpointSynonym {
3939
*
4040
* Create or update multiple [Synonym].
4141
* This method enables you to create or update one or more [Synonym] in a single call.
42-
* You can also recreate your entire set of [Synonym] by using the [replaceExistingSynonyms] parameter.
42+
* You can also recreate your entire set of [Synonym] by using the [clearExistingSynonyms] parameter.
4343
* Note that each [Synonym] object counts as a single indexing operation.
4444
4545
* @param synonyms List of [Synonym] to save.
4646
* @param forwardToReplicas By default, this method applies only to the specified index. By making this true,
4747
* the method will also send the synonym to all replicas. Thus, if you want to forward your synonyms to replicas
4848
* you will need to specify that.
49-
* @param replaceExistingSynonyms Forces the engine to replace all synonyms, using an atomic save.
49+
* @param clearExistingSynonyms Forces the engine to replace all synonyms, using an atomic save.
5050
* Normally, to replace all synonyms on an index, you would first clear the synonyms, using clearAllSynonyms,
5151
* and then create a new list. However, between the clear and the add, your index will have no synonyms.
52-
* This is where replaceExistingSynonyms comes into play.
52+
* This is where clearExistingSynonyms comes into play.
5353
* By adding this parameter, you do not need to use [clearSynonyms], it’s done for you.
5454
* This parameter tells the engine to delete all existing synonyms before recreating a new list from the synonyms
5555
* listed in the current call. This is the only way to avoid having no synonyms, ensuring that your index will
@@ -59,7 +59,7 @@ public interface EndpointSynonym {
5959
suspend fun saveSynonyms(
6060
synonyms: List<Synonym>,
6161
forwardToReplicas: Boolean? = null,
62-
replaceExistingSynonyms: Boolean? = null,
62+
clearExistingSynonyms: Boolean? = null,
6363
requestOptions: RequestOptions? = null
6464
): RevisionIndex
6565

src/commonMain/kotlin/com/algolia/search/endpoint/EndpointSynonymImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ internal class EndpointSynonymImpl(
4040
override suspend fun saveSynonyms(
4141
synonyms: List<Synonym>,
4242
forwardToReplicas: Boolean?,
43-
replaceExistingSynonyms: Boolean?,
43+
clearExistingSynonyms: Boolean?,
4444
requestOptions: RequestOptions?
4545
): RevisionIndex {
4646
if (synonyms.isEmpty()) throw EmptyListException("synonyms")
4747
val path = indexName.toPath("/$RouteSynonyms/batch")
4848
val body = Json.stringify(Synonym.list, synonyms)
4949
val options = requestOptionsBuilder(requestOptions) {
5050
parameter(KeyForwardToReplicas, forwardToReplicas)
51-
parameter(KeyReplaceExistingSynonyms, replaceExistingSynonyms)
51+
parameter(KeyReplaceExistingSynonyms, clearExistingSynonyms)
5252
}
5353

5454
return transport.request(HttpMethod.Post, CallType.Write, path, options, body)

src/commonTest/kotlin/documentation/methods/synonym/DocBatchSynonyms.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal class DocBatchSynonyms {
3131
synonyms = listOf("street", "st")
3232
)
3333
)
34-
index.saveSynonyms(synonyms, forwardToReplicas = true, replaceExistingSynonyms = true)
34+
index.saveSynonyms(synonyms, forwardToReplicas = true, clearExistingSynonyms = true)
3535
}
3636
}
3737
}

0 commit comments

Comments
 (0)