This is documentation for v2 of the Kotlin API clients, which is not the latest version. To see the documentation for the latest version, see Kotlin v3.

Required API Key: any key with the deleteIndex ACL

Method signature
suspend fun Index.deleteObjectBy(
    query: DeleteByQuery,
    requestOptions: RequestOptions? = null
): RevisionIndex

About this method # A

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 # A

Delete records by filter#

1
2
3
4
5
6
val query = DeleteByQuery(
    filters = "category:car",
    aroundLatLng = Point(40.71f, -74.01f)
)

index.deleteObjectsBy(query)

Delete records by filter and send extra HTTP headers#

1
2
3
4
5
6
7
8
9
val query = DeleteByQuery(
    filters = "category:car",
    aroundLatLng = Point(40.71f, -74.01f)
)
val requestOptions = requestOptions {
    headerAlgoliaUserId(UserID("user123"))
}

index.deleteObjectsBy(query, requestOptions)

Parameters # A

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 # A

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?
Kotlin API clients v2