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

# Push records in batches

> Split records into batches and push them through the transformation pipeline.

**Required ACL:** `addObject`, `deleteIndex`, `editSettings`

Use `chunkedPush` to push a large number of records to an index
through the [transformation pipeline](/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data-with-code).

This helper method splits your records into batches (1,000 records by default)
and sends each batch as a [push](/doc/libraries/sdk/methods/ingestion/push) request.
This lets you index large datasets without worrying about request size limits.

To use this method, you need a [Push to Algolia](/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push) connector.

The Search API client helpers,
such as [`saveObjectsWithTransformation`](/doc/libraries/sdk/methods/search/save-objects-with-transformation)
and [`replaceAllObjectsWithTransformation`](/doc/libraries/sdk/methods/search/replace-all-objects-with-transformation),
use `chunkedPush` internally.
Use `chunkedPush` directly on the [Ingestion client](/doc/libraries/sdk/methods/ingestion) if you need more control
over the indexing action or batch size.

This method is subject to [connector limits](/doc/guides/scaling/algolia-service-limits#connectors-limits).

## Usage

<CodeGroup>
  ```cs C# theme={"system"}
  // Initialize the client
  var client = new IngestionClient(
    new IngestionConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
  );

  // Records to push
  var objects = new List<object>
  {
    new { objectID = "1", name = "Record 1" },
    new { objectID = "2", name = "Record 2" },
  };

  // Push records in batches
  var responses = await client.ChunkedPushAsync(
    "INDEX_NAME",
    objects,
    Action.AddObject,
    waitForTasks: true,
    batchSize: 1000
  );
  ```

  ```go Go theme={"system"}
  // Initialize the client with your application region, e.g., ingestion.US
  client, err := ingestion.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", ingestion.US)
  if err != nil {
    panic(err)
  }

  // Records to push
  objects := []map[string]any{
    {"objectID": "1", "name": "Record 1"},
    {"objectID": "2", "name": "Record 2"},
  }

  // Push records in batches
  responses, err := client.ChunkedPush(
    "INDEX_NAME",
    objects,
    ingestion.ActionAddObject,
    nil, // referenceIndexName
    ingestion.WithWaitForTasks(true),
    ingestion.WithBatchSize(1000),
  )
  ```

  ```java Java theme={"system"}
  // Initialize the client
  IngestionClient client = new IngestionClient(
    "ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
  );

  // Records to push
  List<Object> objects = Arrays.asList(
    Map.of("objectID", "1", "name", "Record 1"),
    Map.of("objectID", "2", "name", "Record 2")
  );

  // Push records in batches
  List<WatchResponse> responses = client.chunkedPush(
    "INDEX_NAME",
    objects,
    Action.ADD_OBJECT,
    true,  // waitForTasks
    1000,  // batchSize
    null,  // referenceIndexName
    null   // requestOptions
  );
  ```

  ```js JavaScript theme={"system"}
  import { ingestionClient } from "@algolia/client-ingestion";

  // Initialize the client
  const client = ingestionClient(
    "ALGOLIA_APPLICATION_ID",
    "ALGOLIA_API_KEY",
    "ALGOLIA_APPLICATION_REGION"
  );

  // Records to push
  const objects = [
    { objectID: "1", name: "Record 1" },
    { objectID: "2", name: "Record 2" },
  ];

  // Push records in batches
  const responses = await client.chunkedPush({
    indexName: "INDEX_NAME",
    objects,
    action: "addObject",
    waitForTasks: true,
  });
  ```

  ```php PHP theme={"system"}
  // Initialize the client
  $client = IngestionClient::create(
    'ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION'
  );

  // Records to push
  $objects = [
    ['objectID' => '1', 'name' => 'Record 1'],
    ['objectID' => '2', 'name' => 'Record 2'],
  ];

  // Push records in batches
  $responses = $client->chunkedPush(
    'INDEX_NAME',
    $objects,
    'addObject',
    true,  // waitForTasks
    1000   // batchSize
  );
  ```

  ```python Python theme={"system"}
  from algoliasearch.ingestion.client import IngestionClientSync
  from algoliasearch.ingestion.models.action import Action

  # Initialize the client
  # In an asynchronous context, use IngestionClient instead.
  client = IngestionClientSync(
    "ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
  )

  # Records to push
  objects = [
    {"objectID": "1", "name": "Record 1"},
    {"objectID": "2", "name": "Record 2"},
  ]

  # Push records in batches
  responses = client.chunked_push(
    index_name="INDEX_NAME",
    objects=objects,
    action=Action.ADDOBJECT,
    wait_for_tasks=True,
  )
  ```
</CodeGroup>

## Parameters

<Tabs>
  <Tab title="C#">
    <ParamField body="indexName" type="string" required>
      Name of the index to push records to.
    </ParamField>

    <ParamField body="objects" type="IEnumerable<object>" required>
      Records to push.
    </ParamField>

    <ParamField body="action" type="Action" required>
      [Indexing action](/doc/rest-api/search/batch) to perform on the records,
      such as `AddObject` or `PartialUpdateObject`.
    </ParamField>

    <ParamField body="waitForTasks" type="bool" default={false}>
      Whether to wait for each push task to complete before returning.
    </ParamField>

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

    <ParamField body="referenceIndexName" type="string">
      Index to use as a reference for index settings.
    </ParamField>

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

    <ParamField body="cancellationToken" type="CancellationToken">
      Token to cancel the operation.
    </ParamField>
  </Tab>

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

    <ParamField body="objects" type="[]map[string]any" required>
      Records to push.
    </ParamField>

    <ParamField body="action" type="Action" required>
      [Indexing action](/doc/rest-api/search/batch) to perform on the records,
      such as `ActionAddObject` or `ActionPartialUpdateObject`.
    </ParamField>

    <ParamField body="referenceIndexName" type="*string">
      Index to use as a reference for index settings.
    </ParamField>

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

      <Expandable title="available functions">
        <ParamField body="ingestion.WithWaitForTasks" type="function">
          **Signature:** `func(withWaitForTasks bool) chunkedBatchOption`

          Whether to wait for each push task to complete before returning.
        </ParamField>

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

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

        <ParamField body="ingestion.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="ingestion.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 to push records to.
    </ParamField>

    <ParamField body="objects" type="Iterable<T>" required>
      Records to push.
    </ParamField>

    <ParamField body="action" type="Action" required>
      [Indexing action](/doc/rest-api/search/batch) to perform on the records,
      such as `ADD_OBJECT` or `PARTIAL_UPDATE_OBJECT`.
    </ParamField>

    <ParamField body="waitForTasks" type="boolean" default={false}>
      Whether to wait for each push task to complete before returning.
    </ParamField>

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

    <ParamField body="referenceIndexName" type="String">
      Index to use as a reference for index settings.
    </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 to push records to.
    </ParamField>

    <ParamField body="objects" type="Record<string,unknown>[]" required>
      Records to push.
    </ParamField>

    <ParamField body="action" type="string" default="addObject">
      [Indexing action](/doc/rest-api/search/batch) to perform on the records.
    </ParamField>

    <ParamField body="waitForTasks" type="boolean" default={false}>
      Whether to wait for each push task to complete before returning.
    </ParamField>

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

    <ParamField body="referenceIndexName" type="string">
      Index to use as a reference for index settings.
    </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 to push records to.
    </ParamField>

    <ParamField body="$objects" type="array" required>
      Records to push.
    </ParamField>

    <ParamField body="$action" type="string" default="addObject">
      [Indexing action](/doc/rest-api/search/batch) to perform on the records.
    </ParamField>

    <ParamField body="$waitForTasks" type="bool" default={true}>
      Whether to wait for each push task to complete before returning.
    </ParamField>

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

    <ParamField body="$referenceIndexName" type="string|null">
      Index to use as a reference for index settings.
    </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 to push records to.
    </ParamField>

    <ParamField body="objects" type="list[dict]" required>
      Records to push.
    </ParamField>

    <ParamField body="action" type="Action" default="Action.ADDOBJECT">
      [Indexing action](/doc/rest-api/search/batch) to perform on the records.
    </ParamField>

    <ParamField body="wait_for_tasks" type="bool" default={false}>
      Whether to wait for each push task to complete before returning.
    </ParamField>

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

    <ParamField body="reference_index_name" type="str | None">
      Index to use as a reference for index settings.
    </ParamField>

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