We have about 300,000 unique customers. We have one document each for every order placed, so we have several million order documents since the past 3 years.
How can I get the latest order document for each unique customer's record?
{
"_id" : 1,
"customer_id" : 1001,
"order_amount" : 15.00,
"timestamp" : 1/1/2014,
},
{
"_id" : 2,
"customer_id" : 1001,
"order_amount" : 17.00,
"timestamp" : 1/1/2015,
},
{
"_id" : 3,
"customer_id" : 1002,
"order_amount" : 13.00,
"timestamp" : 1/1/2016,
}
I need the output to be records _id - 2 and 3. Is this possible at all?