Reputation: 1637
While reading in the knowledge center, the following is mentioned:
The TTL properties are not applied to data that already exists in the Analytics Platform. You must set the TTL properties before you add data.
So how can I remove existing logs before setting those properties?
Upvotes: 0
Views: 316
Reputation: 561
You must use the Elastic Search delete APIs to remove existing documents from Worklight Analytics.
Before using any of the Elastic Search delete APIs it is advised to back up your data first, as misuse of the APIs or an undesired query will result in permanent data loss.
Below is an example of how to delete client logs in a specified date range, assuming your instance of Elastic Search is running on http://localhost:9500
. This specific example deletes all client logs between October 1st and October 15th 2014.
curl -XDELETE 'http://localhost:9500/worklight/client_logs/_query' -d
'
{
"query": {
"range": {
"timestamp": {
"gt" : 1412121600000,
"lt" : 1413331200000
}
}
}
}
'
You can delete any type of document using the path http://localhost:9500/worklight/{document_type}
. The types of documents are app_activities, network_activities, notification_activities, client_logs and server_logs.
When deleting documents, you can filter on two properties: "timestamp" or "daystamp", which are both represented in epoch time in milliseconds. Please note, "daystamp" is simply the first timestamp for the given day (i.e. 12:00AM). The range query also accepts the following parameters:
For more information refer to Elastic Search delete and query APIS:
Upvotes: 4