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

# Add or update attributes of multiple records

> Add or update specific record attributes without replacing the entire record.

**Required ACL:** `addObject`

This helper method uses the [Batch operations on one index](/doc/rest-api/search/batch) operation.
It builds a batch request with either the `partialUpdateObject` or `partialUpdateObjectNoCreate` action,
depending on whether `createIfNotExists` is `true` or `false`.
The method sends records in batches of up to 1,000.

This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).

## Usage

<CodeGroup>
  ```cs C# theme={"system"}
  var response = await client.PartialUpdateObjectsAsync(
    "INDEX_NAME",
    new List<Object>
    {
      new Dictionary<string, string> { { "objectID", "1" }, { "name", "Adam" } },
      new Dictionary<string, string> { { "objectID", "2" }, { "name", "Benoit" } },
    },
    true
  );
  ```

  ```go Go theme={"system"}
  response, err := client.PartialUpdateObjects(
    "INDEX_NAME",
    []map[string]any{{"objectID": "1", "name": "Adam"}, {"objectID": "2", "name": "Benoit"}}, search.WithCreateIfNotExists(true))
  if err != nil {
    // handle the eventual error
    panic(err)
  }
  ```

  ```java Java theme={"system"}
  List response = client.partialUpdateObjects(
    "INDEX_NAME",
    Arrays.asList(
      new HashMap() {
        {
          put("objectID", "1");
          put("name", "Adam");
        }
      },
      new HashMap() {
        {
          put("objectID", "2");
          put("name", "Benoit");
        }
      }
    ),
    true
  );
  ```

  ```js JavaScript theme={"system"}
  const response = await client.partialUpdateObjects({
    indexName: 'cts_e2e_partialUpdateObjects_javascript',
    objects: [
      { objectID: '1', name: 'Adam' },
      { objectID: '2', name: 'Benoit' },
    ],
    createIfNotExists: true,
  });
  ```

  ```kotlin Kotlin theme={"system"}
  var response =
    client.partialUpdateObjects(
      indexName = "INDEX_NAME",
      objects =
        listOf(
          buildJsonObject {
            put("objectID", JsonPrimitive("1"))
            put("name", JsonPrimitive("Adam"))
          },
          buildJsonObject {
            put("objectID", JsonPrimitive("2"))
            put("name", JsonPrimitive("Benoit"))
          },
        ),
      createIfNotExists = true,
    )
  ```

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

          ['objectID' => '2',
              'name' => 'Benoit',
          ],
      ],
      true,
  );
  ```

  ```python Python theme={"system"}
  response = client.partial_update_objects(
      index_name="INDEX_NAME",
      objects=[
          {
              "objectID": "1",
              "name": "Adam",
          },
          {
              "objectID": "2",
              "name": "Benoit",
          },
      ],
      create_if_not_exists=True,
  )
  ```

  ```ruby Ruby theme={"system"}
  response = client.partial_update_objects(
    "INDEX_NAME",
    [{objectID: "1", name: "Adam"}, {objectID: "2", name: "Benoit"}],
    true
  )
  ```

  ```scala Scala theme={"system"}
  val response = Await.result(
    client.partialUpdateObjects(
      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"))))
      ),
      createIfNotExists = true
    ),
    Duration(100, "sec")
  )
  ```

  ```swift Swift theme={"system"}
  let response = try await client.partialUpdateObjects(
      indexName: "INDEX_NAME",
      objects: [["objectID": "1", "name": "Adam"], ["objectID": "2", "name": "Benoit"]],
      createIfNotExists: true
  )
  ```
</CodeGroup>

## Parameters

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

    <ParamField body="objects" type="IEnumerable<T>" required>
      Records to update.
    </ParamField>

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

    <ParamField body="createIfNotExists" type="bool" required>
      Whether to add new records to the index if they don't exist yet.
    </ParamField>

    <ParamField body="waitForTasks" type="bool" default={false}>
      Whether to wait until all batch requests are done.
    </ParamField>

    <ParamField body="cancellationToken" type="CancellationToken" default="default">
      Parameter that can be used as a signal to cancel this request.
    </ParamField>
  </Tab>

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

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

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

      <Expandable title="available functions">
        <ParamField body="search.WithCreateIfNotExists" type="function">
          **Signature:** `func(createIfNotExists bool) partialUpdateObjectsOption`

          Whether to add new records to the index if they don't exist yet.
          By default, this function returns `true`.
        </ParamField>

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

          Sets the 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 to update records in.
    </ParamField>

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

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

    <ParamField body="createIfNotExists" type="boolean" default={false}>
      Whether to add new records to the index if they don't exist yet.
    </ParamField>

    <ParamField body="waitForTasks" type="bool" default={false}>
      Whether to wait until all batch requests are done.
    </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 update records in.
    </ParamField>

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

    <ParamField body="createIfNotExists" type="boolean" default="undefined">
      Whether to add new records to the index if they don't exist yet.
    </ParamField>

    <ParamField body="waitForTasks" type="boolean" default={false}>
      Whether to wait until all batch requests are done.
    </ParamField>

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

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

    <ParamField body="objects" type="List<JsonObject>" required>
      Records to update.
    </ParamField>

    <ParamField body="createIfNotExists" type="Boolean" required>
      Whether to add new records to the index if they don't exist yet.
    </ParamField>

    <ParamField body="waitForTasks" type="Boolean" default={false}>
      Whether to wait until all batch requests are done.
    </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 update records in.
    </ParamField>

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

    <ParamField body="createIfNotExists" type="bool" required>
      Whether to add new records to the index if they don't exist yet.
    </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 update records in.
    </ParamField>

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

    <ParamField body="create_if_not_exists" type="bool" default={false}>
      Whether to add new records to the index if they don't exist yet.
    </ParamField>

    <ParamField body="wait_for_task" type="bool" default="False">
      Whether to wait until all batch requests are done.
    </ParamField>

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

  <Tab title="Ruby">
    <ParamField body="index_name" type="String" required>
      Name of the index to update records in.
    </ParamField>

    <ParamField body="objects" type="Array[Hash]" required>
      Records to update.
    </ParamField>

    <ParamField body="create_if_not_exists" type="Boolean">
      Whether to add new records to the index if they don't exist yet.
    </ParamField>

    <ParamField body="wait_for_task" type="Boolean" default={false}>
      Whether to wait until all batch requests are done.
    </ParamField>

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

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

    <ParamField body="objects" type="Seq[Any]" required>
      Records to update.
    </ParamField>

    <ParamField body="createIfNotExists" type="Boolean" default={false}>
      Whether to add new records to the index if they don't exist yet.
    </ParamField>

    <ParamField body="waitForTasks" type="Boolean" default={false}>
      Whether to wait until all batch requests are done.
    </ParamField>

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

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

    <ParamField body="objects" type="[Encodable]" required>
      Records to update.
    </ParamField>

    <ParamField body="createIfNotExists" type="Bool" default={false}>
      Whether to add new records to the index if they don't exist yet.
    </ParamField>

    <ParamField body="waitForTasks" type="Bool" default={false}>
      Whether to wait until all batch requests are done.
    </ParamField>

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