> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Replace all records with transformation

> Replaces all records in an index with new ones, using the transformation pipeline.

**Required ACL:** `addObject`

Before using this method, [set up the transformation region](/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push#set-up-the-transformation-region) on the search client.

To use this method, you must have only one [Push to Algolia](/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push) connector.
The API returns a `400` error if you have more than one Push connector,
or you use [Collections](/doc/guides/solutions/ecommerce/browse/tutorials/collections) *and* a Push connector.

For more information, see [`WithTransformation` helper methods](/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push#search-api-client-withtransformation-helper-methods).

This helper method replaces all records in an index without interrupting ongoing searches.

It combines [batch](/doc/rest-api/search/batch) and [copy/move index](/doc/rest-api/search/operation-index) operations:

1. Copy settings, synonyms, and rules to a temporary index.
2. Add the records from the `objects` parameter to the temporary index.
3. Replace the original index with the temporary one.

If your API key restricts access to specific indices,
make sure it also grants access to the temporary index `INDEX_NAME_tmp_*`
(replace `INDEX_NAME` with the name of your original index).

This method is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia) and [connector limits](/doc/guides/scaling/algolia-service-limits#connectors-limits).

The response includes the results of the individual API requests.

## Usage

<CodeGroup>
  ```cs C# theme={"system"}
  var response = await client.ReplaceAllObjectsWithTransformationAsync(
    "INDEX_NAME",
    new List<Object>
    {
      new Dictionary<string, string> { { "objectID", "1" }, { "name", "Adam" } },
      new Dictionary<string, string> { { "objectID", "2" }, { "name", "Benoit" } },
      new Dictionary<string, string> { { "objectID", "3" }, { "name", "Cyril" } },
      new Dictionary<string, string> { { "objectID", "4" }, { "name", "David" } },
      new Dictionary<string, string> { { "objectID", "5" }, { "name", "Eva" } },
      new Dictionary<string, string> { { "objectID", "6" }, { "name", "Fiona" } },
      new Dictionary<string, string> { { "objectID", "7" }, { "name", "Gael" } },
      new Dictionary<string, string> { { "objectID", "8" }, { "name", "Hugo" } },
      new Dictionary<string, string> { { "objectID", "9" }, { "name", "Igor" } },
      new Dictionary<string, string> { { "objectID", "10" }, { "name", "Julia" } },
    },
    3
  );
  ```

  ```dart Dart theme={"system"}
  final response = await client.replaceAllObjectsWithTransformation(
    indexName: "INDEX_NAME",
    objects: [
      {
        'objectID': "1",
        'name': "Adam",
      },
      {
        'objectID': "2",
        'name': "Benoit",
      },
      {
        'objectID': "3",
        'name': "Cyril",
      },
      {
        'objectID': "4",
        'name': "David",
      },
      {
        'objectID': "5",
        'name': "Eva",
      },
      {
        'objectID': "6",
        'name': "Fiona",
      },
      {
        'objectID': "7",
        'name': "Gael",
      },
      {
        'objectID': "8",
        'name': "Hugo",
      },
      {
        'objectID': "9",
        'name': "Igor",
      },
      {
        'objectID': "10",
        'name': "Julia",
      },
    ],
    batchSize: 3,
  );
  ```

  ```go Go theme={"system"}
  response, err := client.ReplaceAllObjectsWithTransformation(
    "INDEX_NAME",
    []map[string]any{
      {"objectID": "1", "name": "Adam"},
      {"objectID": "2", "name": "Benoit"},
      {"objectID": "3", "name": "Cyril"},
      {"objectID": "4", "name": "David"},
      {"objectID": "5", "name": "Eva"},
      {"objectID": "6", "name": "Fiona"},
      {"objectID": "7", "name": "Gael"},
      {"objectID": "8", "name": "Hugo"},
      {"objectID": "9", "name": "Igor"},
      {"objectID": "10", "name": "Julia"},
    },
    search.WithBatchSize(3),
  )
  if err != nil {
    // handle the eventual error
    panic(err)
  }
  ```

  ```java Java theme={"system"}
  ReplaceAllObjectsWithTransformationResponse response = client.replaceAllObjectsWithTransformation(
    "INDEX_NAME",
    Arrays.asList(
      new HashMap() {
        {
          put("objectID", "1");
          put("name", "Adam");
        }
      },
      new HashMap() {
        {
          put("objectID", "2");
          put("name", "Benoit");
        }
      },
      new HashMap() {
        {
          put("objectID", "3");
          put("name", "Cyril");
        }
      },
      new HashMap() {
        {
          put("objectID", "4");
          put("name", "David");
        }
      },
      new HashMap() {
        {
          put("objectID", "5");
          put("name", "Eva");
        }
      },
      new HashMap() {
        {
          put("objectID", "6");
          put("name", "Fiona");
        }
      },
      new HashMap() {
        {
          put("objectID", "7");
          put("name", "Gael");
        }
      },
      new HashMap() {
        {
          put("objectID", "8");
          put("name", "Hugo");
        }
      },
      new HashMap() {
        {
          put("objectID", "9");
          put("name", "Igor");
        }
      },
      new HashMap() {
        {
          put("objectID", "10");
          put("name", "Julia");
        }
      }
    ),
    3
  );
  ```

  ```js JavaScript theme={"system"}
  const response = await client.replaceAllObjectsWithTransformation({
    indexName: 'cts_e2e_replace_all_objects_with_transformation_javascript',
    objects: [
      { objectID: '1', name: 'Adam' },
      { objectID: '2', name: 'Benoit' },
      { objectID: '3', name: 'Cyril' },
      { objectID: '4', name: 'David' },
      { objectID: '5', name: 'Eva' },
      { objectID: '6', name: 'Fiona' },
      { objectID: '7', name: 'Gael' },
      { objectID: '8', name: 'Hugo' },
      { objectID: '9', name: 'Igor' },
      { objectID: '10', name: 'Julia' },
    ],
    batchSize: 3,
  });
  ```

  ```kotlin Kotlin theme={"system"}
  var response =
    client.replaceAllObjectsWithTransformation(
      indexName = "INDEX_NAME",
      objects =
        listOf(
          buildJsonObject {
            put("objectID", JsonPrimitive("1"))
            put("name", JsonPrimitive("Adam"))
          },
          buildJsonObject {
            put("objectID", JsonPrimitive("2"))
            put("name", JsonPrimitive("Benoit"))
          },
          buildJsonObject {
            put("objectID", JsonPrimitive("3"))
            put("name", JsonPrimitive("Cyril"))
          },
          buildJsonObject {
            put("objectID", JsonPrimitive("4"))
            put("name", JsonPrimitive("David"))
          },
          buildJsonObject {
            put("objectID", JsonPrimitive("5"))
            put("name", JsonPrimitive("Eva"))
          },
          buildJsonObject {
            put("objectID", JsonPrimitive("6"))
            put("name", JsonPrimitive("Fiona"))
          },
          buildJsonObject {
            put("objectID", JsonPrimitive("7"))
            put("name", JsonPrimitive("Gael"))
          },
          buildJsonObject {
            put("objectID", JsonPrimitive("8"))
            put("name", JsonPrimitive("Hugo"))
          },
          buildJsonObject {
            put("objectID", JsonPrimitive("9"))
            put("name", JsonPrimitive("Igor"))
          },
          buildJsonObject {
            put("objectID", JsonPrimitive("10"))
            put("name", JsonPrimitive("Julia"))
          },
        ),
      batchSize = 3,
    )
  ```

  ```php PHP theme={"system"}
  $response = $client->replaceAllObjectsWithTransformation(
      'INDEX_NAME',
      [
          ['objectID' => '1',
              'name' => 'Adam',
          ],

          ['objectID' => '2',
              'name' => 'Benoit',
          ],

          ['objectID' => '3',
              'name' => 'Cyril',
          ],

          ['objectID' => '4',
              'name' => 'David',
          ],

          ['objectID' => '5',
              'name' => 'Eva',
          ],

          ['objectID' => '6',
              'name' => 'Fiona',
          ],

          ['objectID' => '7',
              'name' => 'Gael',
          ],

          ['objectID' => '8',
              'name' => 'Hugo',
          ],

          ['objectID' => '9',
              'name' => 'Igor',
          ],

          ['objectID' => '10',
              'name' => 'Julia',
          ],
      ],
      3,
  );
  ```

  ```python Python theme={"system"}
  response = client.replace_all_objects_with_transformation(
      index_name="INDEX_NAME",
      objects=[
          {
              "objectID": "1",
              "name": "Adam",
          },
          {
              "objectID": "2",
              "name": "Benoit",
          },
          {
              "objectID": "3",
              "name": "Cyril",
          },
          {
              "objectID": "4",
              "name": "David",
          },
          {
              "objectID": "5",
              "name": "Eva",
          },
          {
              "objectID": "6",
              "name": "Fiona",
          },
          {
              "objectID": "7",
              "name": "Gael",
          },
          {
              "objectID": "8",
              "name": "Hugo",
          },
          {
              "objectID": "9",
              "name": "Igor",
          },
          {
              "objectID": "10",
              "name": "Julia",
          },
      ],
      batch_size=3,
  )
  ```

  ```ruby Ruby theme={"system"}
  response = client.replace_all_objects_with_transformation(
    "INDEX_NAME",
    [
      {objectID: "1", name: "Adam"},
      {objectID: "2", name: "Benoit"},
      {objectID: "3", name: "Cyril"},
      {objectID: "4", name: "David"},
      {objectID: "5", name: "Eva"},
      {objectID: "6", name: "Fiona"},
      {objectID: "7", name: "Gael"},
      {objectID: "8", name: "Hugo"},
      {objectID: "9", name: "Igor"},
      {objectID: "10", name: "Julia"}
    ],
    3
  )
  ```

  ```scala Scala theme={"system"}
  val response = Await.result(
    client.replaceAllObjectsWithTransformation(
      indexName = "INDEX_NAME",
      objects = Seq(
        JObject(List(JField("objectID", JString("1")), JField("name", JString("Adam")))),
        JObject(List(JField("objectID", JString("2")), JField("name", JString("Benoit")))),
        JObject(List(JField("objectID", JString("3")), JField("name", JString("Cyril")))),
        JObject(List(JField("objectID", JString("4")), JField("name", JString("David")))),
        JObject(List(JField("objectID", JString("5")), JField("name", JString("Eva")))),
        JObject(List(JField("objectID", JString("6")), JField("name", JString("Fiona")))),
        JObject(List(JField("objectID", JString("7")), JField("name", JString("Gael")))),
        JObject(List(JField("objectID", JString("8")), JField("name", JString("Hugo")))),
        JObject(List(JField("objectID", JString("9")), JField("name", JString("Igor")))),
        JObject(List(JField("objectID", JString("10")), JField("name", JString("Julia"))))
      ),
      batchSize = 3
    ),
    Duration(100, "sec")
  )
  ```

  ```swift Swift theme={"system"}
  let response = try await client.replaceAllObjectsWithTransformation(
      indexName: "INDEX_NAME",
      objects: [
          ["objectID": "1", "name": "Adam"],
          ["objectID": "2", "name": "Benoit"],
          ["objectID": "3", "name": "Cyril"],
          ["objectID": "4", "name": "David"],
          ["objectID": "5", "name": "Eva"],
          ["objectID": "6", "name": "Fiona"],
          ["objectID": "7", "name": "Gael"],
          ["objectID": "8", "name": "Hugo"],
          ["objectID": "9", "name": "Igor"],
          ["objectID": "10", "name": "Julia"],
      ],
      batchSize: 3
  )
  ```
</CodeGroup>

## Parameters

<Tabs>
  <Tab title="Go">
    <ParamField body="indexName" type="string" required>
      Name of the index in which to replace records.
    </ParamField>

    <ParamField body="objects" type="[]map[string]any" required>
      Records that replace the existing records in your index.
    </ParamField>

    <ParamField body="opts..." type="replaceAllObjectsOption">
      Functional options to provide extra arguments.

      <Expandable title="available functions">
        <ParamField body="search.WithScopes" type="function">
          **Signature:** `func(scopes []ScopeType) replaceAllObjectsOption`

          Scopes to include in the replacement operation.
          Can be one or more of `settings`, `synonyms`, or `rules`.
          For more details, see [Scope types](/doc/rest-api/search/operation-index#body-scope).
        </ParamField>

        <ParamField body="search.WithBatchSize" type="function">
          **Signature:** `func(batchSize int) chunkedBatchOption`

          Number of records to process in one batch.
          The default batch size is 1,000.
        </ParamField>

        <ParamField body="search.WithWaitForTasks" type="function">
          **Signature:** `func(withWaitForTasks bool) chunkedBatchOption`

          Whether to wait until all batch requests are done.
        </ParamField>

        <ParamField body="search.WithHeaderParam" type="function">
          **Signature:** `func(key string, value string) requestOption`

          Sets extra header parameters for this request.
          To learn more, see [request options](/doc/libraries/sdk/request-options).
        </ParamField>

        <ParamField body="search.WithQueryParam" type="function">
          **Signature:** `func(key string, value string) requestOption`

          Sets extra query parameters for this request.
          To learn more, see [request options](/doc/libraries/sdk/request-options).
        </ParamField>
      </Expandable>
    </ParamField>
  </Tab>

  <Tab title="Java">
    <ParamField body="indexName" type="String" required>
      Name of the index in which to replace records.
    </ParamField>

    <ParamField body="objects" type="Iterable<T>" required>
      Records that replace the existing records in your index.
    </ParamField>

    <ParamField body="T" type="Type parameter" required>
      The model of your index's records.
    </ParamField>

    <ParamField body="scopes" type="List<ScopeType>" required>
      Scopes to include in the replacement operation.
      Can be one or more of `settings`, `synonyms`, or `rules`.
      For more details, see [Scope types](/doc/rest-api/search/operation-index#body-scope).
    </ParamField>

    <ParamField body="batchSize" type="int" required>
      Number of records to process in one batch.
    </ParamField>

    <ParamField body="requestOptions" type="RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="JavaScript">
    <ParamField body="indexName" type="string" required>
      Name of the index in which to replace records.
    </ParamField>

    <ParamField body="objects" type="Record<string,unknown>[]" required>
      Records that replace the existing records in your index.
    </ParamField>

    <ParamField body="scopes" type="string[]" required>
      Scopes to include in the replacement operation.
    </ParamField>

    <ParamField body="batchSize" type="number" default={1000}>
      Number of records to process in one batch.
    </ParamField>

    <ParamField body="requestOptions" type="RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="PHP">
    <ParamField body="indexName" type="string" required>
      Name of the index in which to replace records.
    </ParamField>

    <ParamField body="objects" type="array" required>
      Records that replace the existing records in your index.
    </ParamField>

    <ParamField body="batchSize" type="int" default={1000}>
      Number of records to process in one batch.
    </ParamField>

    <ParamField body="scopes" type="array" required>
      Scopes to include in the replacement operation.
    </ParamField>

    <ParamField body="requestOptions" type="array">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="Python">
    <ParamField body="index_name" type="str" required>
      Name of the index in which to replace records.
    </ParamField>

    <ParamField body="objects" type="list[dict]" required>
      Records that replace the existing records in your index.
    </ParamField>

    <ParamField body="scopes" type="list[str]" required>
      Scopes to include in the replacement operation.
    </ParamField>

    <ParamField body="batch_size" type="int" default={1000}>
      Number of records to process in one batch.
    </ParamField>

    <ParamField body="request_options" type="dict | RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>
</Tabs>
