Lets say I have 1000 Documents in an index each containing a field name
and a field reportDate
. I know I can aggregate against these fields to find the amount of Documents per unique name
and I know I can sort them by date entered. What I can't figure out is how to get only the earliest entered document per unique name
.
For Example; Lets say we had the following documents:
-
{ name: Sam, reportDate: 2016-03-17 }
-
{ name: Sam, reportDate: 2016-03-13 }
-
{ name: Joe, reportDate: 2016-04-03 }
-
{ name: Joe, reportDate: 2016-05-19 }
After the query I would want only Documents 2 and 3 to be hits; The earliest report per name.
Thanks,
Jeremy