I have a document which can be modified any number of times a day. I've ordered these document in time series creating index for each day. And each day would have multiple versions of the same document with different modified date.
Document sample:
{
  id: 1234,
  user: kc,
  subscriptions: [
    'paper1',
    'paper2'
  ],
  modified_date: 1466697434020
}
What I'm looking for is to get the latest documents in a particular time range for all users and to apply aggregation on top of it.
That would give a result like, in the last week/month how many people are subscribed for each of the papers.
Using top_hits I was able to get the latest document for different users in a time range, but I cannot apply further aggregations on this set of data.
 
    