I have documents with fields account_id(primary key for my relational db) and status. Whenever there is a change in status of the account, I pushed the event to the ElasticSearch.
So over a period of time there will be multiple documents for an account with different statuses.
My requirement is to get the recent document for each account_id and do a count in terms of the status.
SQL equivalent "select status, count(*) from account group by status ;"
Example: consider following logs
account_id: 1, status:delete, @timestamp: November 4th 2017, 18:42:09.445
account_id: 1, status:save, @timestamp: November 3rd 2017, 18:42:09.445
account_id: 1, status:draft, @timestamp: November 2nd 2017, 19:42:09.445
account_id: 2, status:draft, @timestamp: November 3rd 2017, 19:42:09.445
account_id: 3, status:save, @timestamp: November 4th 2017, 18:42:09.445
account_id: 3, status:draft, @timestamp: November 3rd 2017, 19:42:09.445
The output should be:
**status** **count**
delete 1
save 1
draft 1
ELK: 5.6