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

We released a new version of the PHP API client in public beta. Read the beta documentation for more information.

We released a new version of the JavaScript API client in public beta. Read the beta documentation for more information.

We released a new version of the Java API client in public beta. Read the beta documentation for more information.

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.

About this method

Delete records matching a filter (including geo filters).

  • The filter must be included in your attributesForFaceting. For more information, see Define filterable attributes.

  • This operation counts as 1 operation, even if you delete more than one record.

  • This method is subject to rate-limiting. If you get errors when using this method, check if you’re over the rate limit and wait before sending further indexing requests.

    • If you have more than 100 pending requests, your requests will be throttled.
    • If you have more than 1,000 pending requests pending, further requests will be rejected.

You should only use this method if you can’t get a list of object IDs of the records you want to delete. It’s more efficient to get a list of object IDs with the browse method, and then delete the records using deleteObjects. For more information, see Should I use the deleteby method for deleting records matching a query?

Limitations

  • The deleteBy operation can’t be run in parallel.
  • This method does not accept empty filters or queries.

When deleting large numbers of records be aware of the rate limitations on these processes and the impact on your analytics data.

Examples

Read the Algolia CLI documentation for more information.

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

Parameter Description
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. Each API client encapsulates this response inside objects specific to the programming language, so that the actual response might be different. You can view the response by using the getLogs method. Don’t rely on the order of attributes in the response, as JSON doesn’t guarantee the ordering of keys in objects.

JSON format

1
2
3
4
{
  "updatedAt": "2017-12-29T17:34:12.902Z",
  "taskID": 678,
}
Field Description
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?