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

# Partially update objects

> Update one or more attributes of records.

export const Legacy = ({title, href}) => {
  return <Note>

    This page documents an earlier version of the API client.
    For the latest version, see <a href={href}>{title}</a>.

    </Note>;
};

<Legacy title="Add or update attributes of multiple records" href="/doc/libraries/sdk/methods/search/partial-update-objects" />

**Required ACL:** `addObject`

Use this method to add or update attributes of one or more records,
without replacing the whole record.

* If you provide an `objectID` that exists in your index,
  this method adds or updates the attributes of that record,
  without affecting the other attributes.
  To replace whole records, use the [`saveObjects`](/doc/libraries/sdk/v1/methods/save-objects) method instead.

* If you provide an `objectID` that doesn't exist in your index,
  this method creates a new record **unless** the `createIfNotExists` parameter is `false`.

* If you call this method on an index that doesn't exist yet,
  this method creates a new index.

* You can't partially update nested attributes.
  If you specify a nested attribute, this method replaces the first-level ancestor.
  To update nested attributes, use the [`saveObjects`](/doc/libraries/sdk/v1/methods/save-objects) method.
  To retrieve the record's data, use the [`getObjects`](/doc/libraries/sdk/v1/methods/get-objects) method.

<Info>
  When updating large numbers of records, be aware of the [rate limitations](/doc/guides/scaling/algolia-service-limits#application-record-and-index-limits) on these processes and the [impact on your analytics data](/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/concepts/indices-analytics).
</Info>

### Built-in operations

To update an attribute without pushing the entire record, you can use these built-in operations.
These operations can be helpful if you don't have access to your initial data.

* `Increment`: increment a numeric attribute
* `Decrement`: decrement a numeric attribute
* `Add`: append a number or string element to an array attribute
* `Remove`: remove all matching number or string elements from an array attribute made of numbers or strings
* `AddUnique`: add a number or string element to an array attribute made of numbers or strings only if it's not already present
* `IncrementFrom`: increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore the whole object update. For example, if you pass an `IncrementFrom` value of 2 for the `version` attribute, but the current value of the attribute is 1, the engine ignores the update. If the object doesn't exist, the engine only creates it if you pass an `IncrementFrom` value of 0.
* `IncrementSet `: increment a numeric integer attribute only if the provided value is greater than the current value, and otherwise ignore the whole object update. For example, if you pass an `IncrementSet` value of 2 for the `version` attribute, and the current value of the attribute is 1, the engine updates the object. If the object doesn't exist yet, the engine only creates it if you pass an `IncrementSet` value that's greater than 0.

<Info>
  For `Remove` and `AddUnique`: the operation will be silently ignored if the array attribute has any nested object or array.
</Info>

You can specify an operation by providing an object with the attribute to update as the key and its value being an object with the following properties:

* `_operation`: the operation to apply on the attribute
* `value`: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove

<Info>
  **Only the `IncrementFrom` and `IncrementSet` operations guarantee idempotent record updates. The other built-in operations aren't idempotent and can cause unexpected side-effects, unless you use them in combination with the idempotent operations.**
  For example, if you're using the `Increment` or `Decrement` operations in a concurrent or multi-threaded environment, you may trigger it more than once and end up with wrong data in your records.
</Info>

To update a single record, use the [`partialUpdateObject`](#update-one-attribute-of-an-existing-record) method.

## Examples

### Partially update multiple records

<CodeGroup>
  ```cs C# theme={"system"}
  List<Contact> contacts = new List<Contact>
  {
      new Contact { ObjectID = "myID1", Firstname = "Jimmie" },
      new Contact { ObjectID = "myID2", Firstname = "Warren" }
  };

  index.PartialUpdateObjects(contacts);

  // Asynchronous
  await index.PartialUpdateObjectsAsync(contacts);
  ```

  ```go Go theme={"system"}
  objects := []map[string]string{
    {"objectID": "myID1", "lastname": "Barninger"},
    {"objectID": "myID2", "firstname": "Ray"},
  }

  res, err := index.PartialUpdateObjects(objects)
  ```

  ```java Java theme={"system"}
  List<Contact> contacts = Arrays.asList(
    new Contact().setCity("San Francisco").setObjectID("MyID"),
    new Contact().setCity("Paris").setObjectID("MyID2")
  );

  // Sync version
  index.partialUpdateObjects(contacts);

  // Async version
  index.partialUpdateObjectsAsync(contacts);
  ```

  ```js JavaScript theme={"system"}
  const objects = [{
    firstname: 'Jimmie',
    objectID: 'myID1'
  }, {
    firstname: 'Warren',
    objectID: 'myID2'
  }];

  index.partialUpdateObjects(objects).then(({ objectIDs }) => {
    console.log(objectIDs);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  val firstname = Attribute("firstname")
  val partials = listOf(
      ObjectID("myID1") to Partial.Update(firstname, "Jimmie"),
      ObjectID("myID2") to Partial.Update(firstname, "Warren")
  )

  index.partialUpdateObjects(partials)
  ```

  ```php PHP theme={"system"}
  $index->partialUpdateObjects(
      [
          [
              'objectID'  => 'myID1',
              'firstname' => 'Jimmie'
          ],
          [
              'objectID'  => 'myID2',
              'firstname' => 'Warren'
          ]
      ]
  );
  ```

  ```python Python theme={"system"}
  index.partial_update_objects([
      {'objectID': 'myID1', 'firstname': 'Jimmie'},
      {'objectID': 'myID2', 'firstname': 'Warren'}
  ])
  ```

  ```ruby Ruby theme={"system"}
  index.partial_update_objects([{
    firstname: 'Jimmie',
    objectID: 'myID'
  }, {
    firstname: 'Warren',
    objectID: 'myID2'
  }])
  ```

  ```scala Scala theme={"system"}
  client.execute {
    partialUpdate from "index" objects Seq(
      Contact("myID", "Jimmie", "Barninger"),
      Contact("myID", "Speach")
    )
  }
  ```

  ```swift Swift theme={"system"}
  let updates: [(ObjectID, PartialUpdate)] = [
    ("myID1", .update(attribute: "firstname", value: "Jimmie")),
    ("myID2", .update(attribute: "firstname", value: "Warren"))
  ]

  index.partialUpdateObjects(updates: updates) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

### Partially update multiple records and send extra HTTP headers

<CodeGroup>
  ```cs C# theme={"system"}
  List<Contact> contacts = new List<Contact>
  {
      new Contact { ObjectID = "myID1", Firstname = "Jimmie" },
      new Contact { ObjectID = "myID2", Firstname = "Warren" }
  };

  RequestOptions requestOptions = new RequestOptions
  {
      Headers = new Dictionary<string,string>{ { "X-Algolia-User-ID", "user123" } }
  };

  index.PartialUpdateObjects(contacts, requestOptions);

  // Asynchronous
  await index.PartialUpdateObjectsAsync(contacts, requestOptions);
  ```

  ```go Go theme={"system"}
  objects := []map[string]string{
    {"objectID": "myID1", "lastname": "Barninger"},
    {"objectID": "myID2", "firstname": "Ray"},
  }

  extraHeaders := opt.ExtraHeaders(map[string]string{
    "X-Algolia-User-ID": "userID2",
  })

  res, err := index.PartialUpdateObjects(objects, extraHeaders)
  ```

  ```java Java theme={"system"}
  List<Contact> contacts = Arrays.asList(
    new Contact().setCity("San Francisco").setObjectID("MyID"),
    new Contact().setCity("Paris").setObjectID("MyID2")
  );

  RequestOptions requestOptions =
      new RequestOptions().addExtraHeader("X-Algolia-User-ID", "user123")

  // Sync version
  index.partialUpdateObjects(contacts, requestOptions);

  // Async version
  index.partialUpdateObjectsAsync(contacts, requestOptions);
  ```

  ```js JavaScript theme={"system"}
  index.partialUpdateObjects(objects, {
    createIfNotExists: true,
    headers: {
      'X-Forwarded-For': '94.228.178.246'
    }
  }).then(({ objectIDs }) => {
    console.log(objectIDs);
  });

  ```

  ```kotlin Kotlin theme={"system"}
  val firstname = Attribute("firstname")
  val partials = listOf(
      ObjectID("myID1") to Partial.Update(firstname, "Jimmie"),
      ObjectID("myID2") to Partial.Update(firstname, "Warren")
  )
  val requestOptions = requestOptions {
      headerAlgoliaUserId(UserID("user123"))
  }

  index.partialUpdateObjects(partials, requestOptions = requestOptions)
  ```

  ```php PHP theme={"system"}
  $objects = [/* objects */];

  $res = $index->partialUpdateObjects($objects, [
    'createIfNotExists' => true,
    'X-Forwarded-For' => '94.228.178.246'
  ]);
  ```

  ```python Python theme={"system"}
  objects = [
        # Objects
  ]
  index.partial_update_objects(objects, {'X-Forwarded-For': '94.228.178.246'})
  ```

  ```ruby Ruby theme={"system"}
  objects = [
    # your objects here
  ]

  res = index.partial_update_objects(objects, {
    createIfNotExists: true,
    headers: {
      'X-Forwarded-For': '94.228.178.246'
    }
  })
  ```

  ```scala Scala theme={"system"}
  client.execute {
    client.execute {
      partialUpdate from "index" objects Seq(
        Contact("myID", "Jimmie", "Barninger"),
        Contact("myID", "Speach")
      ) options RequestOptions(
        extraHeaders = Some(Map("X-Algolia-User-ID" => "user123"))
      )
    }
  }
  ```

  ```swift Swift theme={"system"}
  var requestOptions = RequestOptions()
  requestOptions.headers["X-Algolia-User-ID"] = "user123"

  let updates: [(ObjectID, PartialUpdate)] = [
    ("myID1", .update(attribute: "firstname", value: "Jimmie")),
    ("myID2", .update(attribute: "firstname", value: "Warren"))
  ]

  index.partialUpdateObjects(updates: updates, requestOptions: requestOptions) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

### Update one attribute of an existing record

This example updates only the `city` attribute of a single record

<CodeGroup>
  ```cs C# theme={"system"}
  var contact = new Contact { ObjectID = "myID", City = "San Francisco"" };

  index.PartialUpdateObject(contact);

  // Asynchronous
  await index.PartialUpdateObjectAsync(contact);
  ```

  ```go Go theme={"system"}
  type Contact struct {
  	ObjectID string `json:"objectID"`
  	City     string `json:"city"`
  }

  contact := Contact{
  	ObjectID: "myID",
  	City:     "San Francisco",
  }

  res, err := index.PartialUpdateObject(contact)
  ```

  ```java Java theme={"system"}
  Contact contact = new Contact().setObjectID("myID").setCity("San Francisco");

  // Sync version
  index.partialUpdateObject(contact);

  // Sync version
  index.partialUpdateObjectAsync(contact);
  ```

  ```js JavaScript theme={"system"}
  index.partialUpdateObject({
    city: 'San Francisco',
    objectID: 'myID'
  }).then(({ objectID }) => {
    console.log(objectID);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  val partial = Partial.Update(Attribute("city"), "San Francisco")

  index.partialUpdateObject(ObjectID("myID"), partial)
  ```

  ```php PHP theme={"system"}
  $index->partialUpdateObject(
    [
      'city'     => 'San Francisco',
      'objectID' => 'myID'
    ]
  );
  ```

  ```python Python theme={"system"}
  index.partial_update_object({"objectID": "myID", "city": "San Francisco"})
  ```

  ```ruby Ruby theme={"system"}
  index.partial_update_object({
    city: 'San Francisco',
    objectID: 'myID'
  })
  ```

  ```scala Scala theme={"system"}
  client.execute {
    partialUpdate from "index" `object` Contact(
      objectID = "myID",
      city = "San Francisco"
    )
  }
  ```

  ```swift Swift theme={"system"}
  index.partialUpdateObject(withID: "myID", with: .update(attribute: "city", value: "San Francisco")) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

### Add a new attribute to an existing record

This example adds a `state` attribute to a single record.

<CodeGroup>
  ```cs C# theme={"system"}
  index.PartialUpdateObject(new Contact { ObjectID = "myID1", State = "California" });

  // Asynchronous
  await index.PartialUpdateObjectAsync(new Contact { ObjectID = "myID1", State = "California" });
  ```

  ```go Go theme={"system"}
  type Contact struct {
  	ObjectID string `json:"objectID"`
  	State    string `json:"state"`
  }

  contact := Contact{
  	ObjectID: "myID",
  	State:    "California",
  }

  res, err := index.PartialUpdateObject(contact)
  ```

  ```java Java theme={"system"}
  Contact contact = new Contact().setObjectID("myID").setState("California");

  // Sync version
  index.partialUpdateObject(contact);

  // Sync version
  index.partialUpdateObjectAsync(contact);
  ```

  ```js JavaScript theme={"system"}
  index.partialUpdateObject({
    state: 'California',
    objectID: 'myID'
  }).then(({ objectID }) => {
    console.log(objectID);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  val partial = Partial.Update(Attribute("state"), "California")

  index.partialUpdateObject(ObjectID("myID"), partial)
  ```

  ```php PHP theme={"system"}
  $index->partialUpdateObject(
    [
      'state'    => 'California',
      'objectID' => 'myID'
    ]
  );
  ```

  ```python Python theme={"system"}
  index.partial_update_object({'objectID': 'myID', 'state': 'California'})
  ```

  ```ruby Ruby theme={"system"}
  index.partial_update_object({
    state: 'California',
    objectID: 'myID'
  })
  ```

  ```scala Scala theme={"system"}
  client.execute {
    partialUpdate from "index" `object` Contact(
      objectID = "myID",
      state = "California"
    )
  }
  ```

  ```swift Swift theme={"system"}
  index.partialUpdateObject(withID: "myID", with: .update(attribute: "state", value: "California")) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

### Increment a numeric attribute

This example updates the `count` attribute and increments its value.

<CodeGroup>
  ```cs C# theme={"system"}
  class Record
  {
      public string ObjectID { get; set; }

      public PartialUpdateOperation<int> Count { get; set; }
  }

  var record = new Record
  {
      ObjectID = "myID",
      Count = PartialUpdateOperation<int>.Increment(2),
  };

  var res = index.PartialUpdateObjects(new List<Record>
  {
      record
  });
  ```

  ```go Go theme={"system"}
  type Record struct {
      ObjectID string                        `json:"objectID"`
      Count    search.PartialUpdateOperation `json:"count"`
  }

  res, err := index.PartialUpdateObjects([]Record{
      {
          ObjectID: "myID",
          Count: search.PartialUpdateOperation{
              Operation: "Increment",
              Value:     2,
          },
      },
  })
  ```

  ```java Java theme={"system"}
  class RecordWithPartialUpdate {
      private String objectID;
      private PartialUpdateOperation<Integer> count;

      public Record(String objectID, PartialUpdateOperation<Integer> count) {
          this.objectID = objectID;
          this.count = count;
      }

      // Getters and setters omitted for readability
  }

  BatchIndexingResponse res = index.partialUpdateObjects(Collections.singletonList(
      new Record("myID", PartialUpdateOperation.Increment(2))
  ));
  ```

  ```js JavaScript theme={"system"}
  index.partialUpdateObject({
    count: {
      _operation: 'Increment',
      value: 2,
    },
    objectID: 'myID',
  })
  .then(({ objectIDs }) => {
    console.log(objectIDs);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  val partial = Partial.Update(Attribute("Increment"), 2)
  index.partialUpdateObject(ObjectID("myID"), partial)
  ```

  ```php PHP theme={"system"}
  $index->partialUpdateObject(
    [
      'count'    => [
        '_operation' => 'Increment',
        'value'      => 2
      ],
      'objectID' => 'myID'
    ]
  );
  ```

  ```python Python theme={"system"}
  index.partial_update_object({
    'count': {
      '_operation': 'Increment',
      'value': 2
    },
    'objectID': 'myID'
  })
  ```

  ```ruby Ruby theme={"system"}
  index.partial_update_object({
    count: {
      _operation: 'Increment',
      value: 2
    },
    objectID: 'myID'
  })
  ```

  ```scala Scala theme={"system"}
  client.execute {
    increment attribute "count" by 2 ofObjectId "myID" from "indexName"
  }
  ```

  ```swift Swift theme={"system"}
  index.partialUpdateObject(withID: "myID", with: .increment(attribute: "count", value: 2)) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

### Add a new value to an existing array attribute

This example updates the `_tags` attribute and adds an item to the list.

<CodeGroup>
  ```cs C# theme={"system"}
  class Record
  {
      public string ObjectID { get; set; }

      [JsonProperty(PropertyName = "_tags")]
      public PartialUpdateOperation<string> Tags { get; set; }
  }

  var record = new Record
  {
      ObjectID = "myID",
      Tags = PartialUpdateOperation<string>.AddUnique("public"),
  };

  var res = index.PartialUpdateObjects(new List<Record>
  {
      record
  });
  ```

  ```go Go theme={"system"}
  type Record struct {
      ObjectID string                        `json:"objectID"`
      Tags     search.PartialUpdateOperation `json:"_tags"`
  }

  res, err := index.PartialUpdateObjects([]Record{
      {
          ObjectID: "myID",
          Tags: search.PartialUpdateOperation{
              Operation: "AddUnique",
              Value:     "public",
          },
      },
  })
  ```

  ```java Java theme={"system"}
  class RecordWithPartialUpdate {
      private String objectID;

      @JsonProperty("_tags")
      private PartialUpdateOperation<String> tags;

      public Record(String objectID, PartialUpdateOperation<String> tags) {
          this.objectID = objectID;
          this.tags = tags;
      }

      // Getters and setters omitted for readability
  }

  BatchIndexingResponse res = index.partialUpdateObjects(Collections.singletonList(
      new Record("myID", PartialUpdateOperation.AddUnique("public"))
  ));
  ```

  ```js JavaScript theme={"system"}
  index.partialUpdateObject({
    _tags: {
      _operation: 'AddUnique',
      value: 'public',
    },
    objectID: 'myID',
  })
  .then(({ objectIDs }) => {
    console.log(objectIDs);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  val partial = Partial.AddUnique(Attribute("_tags"), "public")
  index.partialUpdateObject(ObjectID("myID"), partial)
  ```

  ```php PHP theme={"system"}
  $index->partialUpdateObject(
    [
      '_tags'    => [
        '_operation' => 'AddUnique',
        'value'      => 'public'
      ],
      'objectID' => 'myID'
    ]
  );
  ```

  ```python Python theme={"system"}
  index.partial_update_object({
    '_tags': {
      '_operation': 'AddUnique',
      'value': 'public'
    },
    'objectID': 'myID'
  })
  ```

  ```ruby Ruby theme={"system"}
  index.partial_update_object({
    _tags: {
      _operation: 'AddUnique',
      value: 'public'
    },
    objectID: 'myID'
  })
  ```

  ```scala Scala theme={"system"}
  client.execute {
    addUnique value "public" inAttribute "_tags" ofObjectId "myID" from "indexName"
  }
  ```

  ```swift Swift theme={"system"}
  index.partialUpdateObject(withID: "myID", with: .add(attribute: "_tags", value: "public", unique: true)) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

### Update only if the value matches a numeric attribute

This example updates the `version` attribute using the `IncrementFrom` built-in operation. This ensures that this attribute is only incremented if the provided value  matches.

<CodeGroup>
  ```cs C# theme={"system"}
  class Record
  {
      public string ObjectID { get; set; }

      public PartialUpdateOperation<int> Count { get; set; }
  }

  var record = new Record
  {
      ObjectID = "myID",
      Count = PartialUpdateOperation<int>.IncrementFrom(2),
  };

  var res = index.PartialUpdateObjects(new List<Record>
  {
      record
  });
  ```

  ```go Go theme={"system"}
  type Record struct {
      ObjectID string                        `json:"objectID"`
      Count    search.PartialUpdateOperation `json:"version"`
  }

  res, err := index.PartialUpdateObjects([]Record{
      {
          ObjectID: "myID",
          Count: search.PartialUpdateOperation{
              Operation: "IncrementFrom",
              Value:     2,
          },
      },
  })
  ```

  ```java Java theme={"system"}
  class RecordWithPartialUpdate {
      private String objectID;
      private PartialUpdateOperation<Integer> version;

      public Record(String objectID, PartialUpdateOperation<Integer> version) {
          this.objectID = objectID;
          this.version = version;
      }

      // Getters and setters omitted for readability
  }

  BatchIndexingResponse res = index.partialUpdateObjects(Collections.singletonList(
      new Record("myID", PartialUpdateOperation.incrementFrom(2))
  ));
  ```

  ```js JavaScript theme={"system"}
  index.partialUpdateObject({
    version: {
      _operation: 'IncrementFrom',
      value: 2,
    },
    objectID: 'myID',
  })
  .then(({ objectIDs }) => {
    console.log(objectIDs);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  val partial = Partial.IncrementFrom(Attribute("version"), 2)
  index.partialUpdateObject(ObjectID("myID"), partial)
  ```

  ```php PHP theme={"system"}
  $index->partialUpdateObject(
    [
      'version'    => [
        '_operation' => 'IncrementFrom',
        'value'      => 2
      ],
      'objectID' => 'myID'
    ]
  );
  ```

  ```python Python theme={"system"}
  index.partial_update_object({
    'version': {
      '_operation': 'IncrementFrom',
      'value': 2
    },
    'objectID': 'myID'
  })
  ```

  ```ruby Ruby theme={"system"}
  index.partial_update_object({
    version: {
      _operation: 'IncrementFrom',
      value: 2
    },
    objectID: 'myID'
  })
  ```

  ```scala Scala theme={"system"}
  client.execute {
    increment from "version" by 2 ofObjectId "myID" from "indexName"
  }
  ```

  ```swift Swift theme={"system"}
  index.partialUpdateObject(withID: "myID", with: .incrementFrom(attribute: "version", value: 2)) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

### Update only if the value is greater than a numeric attribute

This example updates the `lastmodified` attribute using the `IncrementSet` built-in operation to ensure that only the highest increment value is set.

<CodeGroup>
  ```cs C# theme={"system"}
  class Record
  {
      public string ObjectID { get; set; }

      public PartialUpdateOperation<int> Count { get; set; }
  }

  var record = new Record
  {
      ObjectID = "myID",
      Count = PartialUpdateOperation<int>.IncrementSet(1593431913),
  };

  var res = index.PartialUpdateObjects(new List<Record>
  {
      record
  });
  ```

  ```go Go theme={"system"}
  type Record struct {
      ObjectID string                        `json:"objectID"`
      Count    search.PartialUpdateOperation `json:"lastmodified"`
  }

  res, err := index.PartialUpdateObjects([]Record{
      {
          ObjectID: "myID",
          Count: search.PartialUpdateOperation{
              Operation: "IncrementSet",
              Value:     1593431913,
          },
      },
  })
  ```

  ```java Java theme={"system"}
  class RecordWithPartialUpdate {
      private String objectID;
      private PartialUpdateOperation<Integer> lastmodified;

      public Record(String objectID, PartialUpdateOperation<Integer> lastmodified) {
          this.objectID = objectID;
          this.lastmodified = lastmodified;
      }

      // Getters and setters omitted for readability
  }

  BatchIndexingResponse res = index.partialUpdateObjects(Collections.singletonList(
      new Record("myID", PartialUpdateOperation.incrementSet(1593431913))
  ));
  ```

  ```js JavaScript theme={"system"}
  index.partialUpdateObject({
    lastmodified: {
      _operation: 'IncrementSet',
      value: 1593431913,
    },
    objectID: 'myID',
  })
  .then(({ objectIDs }) => {
    console.log(objectIDs);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  val partial = Partial.IncrementSet(Attribute("lastmodified"), 1593431913)
  index.partialUpdateObject(ObjectID("myID"), partial)
  ```

  ```php PHP theme={"system"}
  $index->partialUpdateObject(
    [
      'lastmodified'    => [
        '_operation' => 'IncrementSet',
        'value'      => 1593431913
      ],
      'objectID' => 'myID'
    ]
  );
  ```

  ```python Python theme={"system"}
  index.partial_update_object({
    'lastmodified': {
      '_operation': 'IncrementSet',
      'value': 1593431913
    },
    'objectID': 'myID'
  })
  ```

  ```ruby Ruby theme={"system"}
  index.partial_update_object({
    lastmodified: {
      _operation: 'IncrementSet',
      value: 1593431913
    },
    objectID: 'myID'
  })
  ```

  ```scala Scala theme={"system"}
  client.execute {
    increment set "lastmodified" by 1593431913 ofObjectId "myID" from "indexName"
  }
  ```

  ```swift Swift theme={"system"}
  index.partialUpdateObject(withID: "myID", with: .incrementSet(attribute: "lastmodified", value: 1593431913)) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="objects" type="object[]" required>
  List of [records](/doc/libraries/sdk/v1/methods/partial-update-objects#param-objects) to update.
  (Required for `partial_update_objects`).

  <Expandable>
    <ParamField body="objectID" type="string" required>
      Object ID of a record to update.
      If the `objectID` doesn't exist,
      the behavior of this method depends on the [`createIfNotExists`](/doc/libraries/sdk/v1/methods/partial-update-objects#param-create-if-not-exists) parameter.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="createIfNotExists" type="boolean" default={true}>
  If `true`, updating a record with a non-existing `objectID` creates a new record with the specified attributes.
  If `false` (the `objectID` doesn't exist), the update will be ignored. This means that no error will be returned, and the record won't be updated.

  <Info>
    In the Java, JavaScript, Ruby, Python, PHP, and .NET API clients, this parameter defaults to `false`.
  </Info>
</ParamField>

<ParamField body="requestOptions" type="object">
  A mapping of request options to send along with the query.
</ParamField>

## Response

<ResponseField name="objectIDs" type="list">
  List of object IDs of the records that should be updated.
</ResponseField>

<ResponseField name="taskID" type="integer">
  The task ID used with the [`waitTask`](/doc/libraries/sdk/v1/methods/wait-task) method.
</ResponseField>

### Response as JSON

This section shows the JSON response returned by the API.
Each API client wraps this response in language-specific objects, so the structure may vary.
To view the response, use the `getLogs` method.
Don't rely on the order of properties—JSON objects don't preserve key order.

```jsonc JSON icon=braces theme={"system"}
{
  "objectIDs": [
    "myObjectID1",
    "myObjectID2"
  ],
  "taskID": 678,
}
```
