API Reference / API Methods / Indexing / Delete by
Required API Key: any key with the deleteIndex ACL
Method signature
$index->deleteBy(array filterParameters)
$index->deleteBy(array filterParameters, array requestOptions)

About this method

You’re currently reading the JavaScript API client v4 documentation. Check the migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.

You’re currently reading the Ruby API client v2 documentation. Check the migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.

Remove all objects matching a filter (including geo filters).

This method enables you to delete one or more objects based on filters (numeric, facet, tag or geo queries).

It doesn’t accept empty filters or a query.

This method should only be used if you can’t get the list of objectIDs you want to delete; The engine can’t process these operations in parallel. If possible, use the delete method instead which is significantly more performant.

The delete by method only counts as 1 operation - even if it deletes more than one object. This is exceptional; most indexing options that affect more than one object normally count each object as a separate operation.

When sending multiple deleteBy operations, be aware of the rate limit. You’ll know you’ve reached the rate limit when you start receiving errors on your indexing operations. This can only be resolved if you wait before sending any further indexing operations.

Note this is an expensive operation:

  • when you have more than 100 requests pending, your requests will be throttled.
  • when you have more than 1000 requests pending, further requests will be rejected.
  • if needed, these values can be tuned through configuration.

Examples

Delete records by filter

1
2
3
4
5
$index->deleteBy([
  'filters' => 'category:cars',
  'aroundLatLng' => '40.71, -74.01'
  /* add any filter parameters */
]);

Delete records by filter and send extra HTTP headers

1
2
3
4
5
6
7
8
9
$params = [
  'filters' => 'category:cars',
  'aroundLatLng' => '40.71, -74.01'
  /* add any filter parameters */
];

$index->deleteBy($params, [
  'X-Algolia-User-ID' => 'user123'
]);

Parameters

filterParameters
type: key-value mapping
Required

An object with one or more of the following parameters:

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

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

Response

This section shows the JSON response returned by the API. Since each language encapsulates this response inside objects specific to that language and/or implementation, the actual type in your language might differ from what’s written here. You can view the response in the logs (using the getLogs method).

JSON format

1
2
3
4
{
  "updatedAt": "2017-12-29T17:34:12.902Z",
  "taskID": 678,
}
updatedAt
string

Date at which the indexing job has been created.

taskID
integer

The taskID used with the waitTask method.

Did you find this page helpful?