Skip to content

Commit 8a84d47

Browse files
chore: generated code for commit de409078. [skip ci]
algolia/api-clients-automation@de40907 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent b05a0ef commit 8a84d47

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

packages/client-search/src/searchClient.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ export function createSearchClient({
579579

580580
/**
581581
* Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
582+
* See https://api-clients-automation.netlify.app/docs/contributing/add-new-api-client#5-helpers for implementation details.
582583
*
583584
* @summary Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
584585
* @param replaceAllObjects - The `replaceAllObjects` object.
@@ -594,7 +595,7 @@ export function createSearchClient({
594595
const randomSuffix = Math.random().toString(36).substring(7);
595596
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
596597

597-
const copyOperationResponse = await this.operationIndex(
598+
let copyOperationResponse = await this.operationIndex(
598599
{
599600
indexName,
600601
operationIndexParams: {
@@ -605,15 +606,32 @@ export function createSearchClient({
605606
},
606607
requestOptions
607608
);
609+
610+
const batchResponses = await this.chunkedBatch(
611+
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
612+
requestOptions
613+
);
614+
608615
await this.waitForTask({
609-
indexName,
616+
indexName: tmpIndexName,
610617
taskID: copyOperationResponse.taskID,
611618
});
612619

613-
const batchResponses = await this.chunkedBatch(
614-
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
620+
copyOperationResponse = await this.operationIndex(
621+
{
622+
indexName,
623+
operationIndexParams: {
624+
operation: 'copy',
625+
destination: tmpIndexName,
626+
scope: ['settings', 'rules', 'synonyms'],
627+
},
628+
},
615629
requestOptions
616630
);
631+
await this.waitForTask({
632+
indexName: tmpIndexName,
633+
taskID: copyOperationResponse.taskID,
634+
});
617635

618636
const moveOperationResponse = await this.operationIndex(
619637
{
@@ -623,7 +641,7 @@ export function createSearchClient({
623641
requestOptions
624642
);
625643
await this.waitForTask({
626-
indexName,
644+
indexName: tmpIndexName,
627645
taskID: moveOperationResponse.taskID,
628646
});
629647

0 commit comments

Comments
 (0)