Deleting Old Items in a Push Source
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.
DELETE /sources/{sourceId}/documents/olderthan
Push API request (highlighted) as it progresses through the Coveo indexing pipeline.
Request template
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:
- Replace
<MyOrganizationId>
with the ID of the target Coveo organization (see Retrieve the organization ID). - Replace
<MySourceId>
with the ID of the target Push source.
In the query string:
-
Replace
<MyOrderingId>
with theorderingId
value you want to use. Any item that was pushed by an operation whoseorderingId
is lower (“older”) than this value will be deleted from the target Push source (see About the orderingId Parameter).Unless you’re setting your own
orderingId
values when pushing items, you should typically set theorderingId
of a Delete old items operation to the current number of milliseconds since the UNIX epoch, without any offset.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 itsorderingId
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.The default
queueDelay
value is15
(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:
-
Replace
<MyAccessToken>
with an access token that grants the Sources - Edit privilege on the target source, if not already done.You can create an API key and use its token, or use the token of your user (see Get your Coveo access token).
Get the privileges of the access token to validate that the token has the required privileges.
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.
This doesn’t imply that the items were successfully deleted in the target Push source (see About the Push API Processing Delay).
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
Deleting 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