I have been working on getting an use case executed, basically, we will have multiple versions of a given record and we differentiate them using the date they were inserted. use case is that we have to get the latest version of that record that falls under the given date range. For this i have used aggregations.
My query works just fine for most of the cases, but for one case. Based on my knowledge, if we can perform aggregations first and then apply the search queries on each of the buckets that are formed, all of the use cases will work.
So my question is, can we perform aggregations first and then apply search to each of the bucket.?
Please help if there is any other alternative.