Deleting old items in a Push source

You can perform a single Push API call to delete all of the items in a Push source that were last updated with a Push API operation whose orderingId value is lower than a specified value (see About the orderingId parameter).

This article provides an overview of the DELETE /sources/{sourceId}/documents/olderthan HTTP request.

Sequence diagram for DELETE older than request
Sequence diagram illustrating the handling of a DELETE /sources/{sourceId}/documents/olderthan Push API request (highlighted) as it progresses through the Coveo indexing pipeline.

Request template

Request definition

DELETE https://api.cloud.coveo.com/push/v1/organizations/<MyOrganizationId>/sources/<MySourceId>/documents/olderthan?orderingId=<MyOrderingId>&queueDelay=<MyQueueDelay> HTTP/1.1

Accept: application/json
Authorization: Bearer <MyAccessToken>

In the request path:

In the query string:

  • Replace <MyOrderingId> with the orderingId value you want to use. Any item that was pushed by an operation whose orderingId is lower ("older") than this value will be deleted from the target Push source (see About the orderingId parameter).

    Important

    Unless you’re setting your own orderingId values when pushing items, you should typically set the orderingId of a Delete old items operation to the current number of milliseconds since the UNIX epoch, without any offset.

    Example

    You’re letting the Push API set its own orderingId values when you push content updates to your source. This means that each content update operation you perform on that source has its orderingId automatically set to the current number of milliseconds since the UNIX epoch, which is UTC-based.

    When performing a Delete old items operation on that source, you retrieve the current UNIX timestamp, but then mistakenly adjust it to Central European Standard Time (that is, UTC+1) before setting it as the orderingId value. As a result, the indexing pipeline will reject new pushed items for an hour after you perform the operation.

  • Optionally, replace <MyQueueDelay> with the number of minutes you want the Push API to wait before enqueueing the Delete old items operation in the indexing pipeline.

    Note

    The default queueDelay value is 15 (minutes).

    This grace period is intended to give the indexing pipeline enough time to finish processing any previously enqueued operations that would affect the target Push source.

    Performing a Delete old items operation with a low queueDelay value may have unexpected results (that is, some items you expect to be deleted could be added back into the target Push source after the operation is processed).

In the Authorization HTTP header:

A successful response (202 Accepted) has no content, but it indicates that the Delete old items operation was forwarded to the service. It will be enqueued to be processed by the indexing pipeline when the specified (or default) queueDelay has elapsed.

Note

This doesn’t imply that the items were successfully deleted in the target Push source (see About the Push API processing delay).

Tip
Leading practice: Update the status of your Push source

If you set your Push source to an active status before, and you have no further operations to perform as part of this content update, you should consider setting it back to the IDLE status after this operation has successfully returned (see Updating the status of a Push source).

Sample request

The following example shows how to delete all items older than a specified orderingId value.

DELETE https://api.cloud.coveo.com/push/v1/organizations/mycoveocloudv2organizationg8tp8wu3/sources/mycoveocloudv2organization-rp5rxzbdz753uhndklv2ztkfgy/documents/olderthan?orderingId=1509711177594&queueDelay=1 HTTP/1.1

Accept: application/json
Authorization: Bearer **********-****-****-****-************

Successful response - 202 Accepted

null