API Reference / API Methods / Indexing / Delete objects
Feb. 26, 2019

Delete objects

Required API Key: any key with the deleteObject ACL
Method signature
$index->deleteObjects(array objectIds)
$index->deleteObjects(array objectIds, array requestOptions)

// delete a single object
$index->deleteObject(string objectID)
$index->deleteObject(string objectID, array requestOptions)

About this method

Remove objects from an index using their object ids.

This method enables you to remove one or more objects from an index.

There are 2 methods available to delete objects:

  • this one, which uses an objectID to identify objects
  • and delete by, which uses filters to identify objects

Note: This method also has a singular version.

Examples

Delete multiple objects using their objectIDs

1
$index->deleteObjects(["myID1", "myID2"]);

Delete a single object

1
$index->deleteObject('myID');

Delete multiple objects and send extra http headers

1
2
3
4
5
$objectIDs = [/* objectIDs */];

$index->deleteObjects($objectIDs, [
  'X-FORWARDED-FOR' => '94.228.178.246'
]);

Parameters

objectIDs
type: list
Required

List of objectIDs to delete.

requestOptions
type: key value mapping
default: No request options
Optional

A mapping of request options to send along with the query.

objectID
type: integer|string
Required

The objectID of the object to delete.

Response

In this section we document the JSON response returned by the API. Each language will encapsulate this response inside objects specific to the language and/or the implementation. So the actual type in your language might differ from what is documented.

JSON format

1
2
3
4
5
6
7
{
  "objectIDs": [
    "myObjectID1",
    "myObjectID2"
  ],
  "taskID": 678,
}
objectIDs
list

List of the objectIDS of the deleted objects.

taskID
integer

The taskID used with the waitTask method.

Did you find this page helpful?