Hi there,
I want to control the number of documents in our index, so I'm planning on running a delete by query periodically. Our documents look something like this:
{
"client": "a51b8afa8710ccbad1",
"createdAt": "2021-01-19T13:45:21.000Z",
"otherfields": "a lot of data"
}
For our use case only the most recent 10k documents per client are relevant. Given our large number of clients, we want to make sure we're keeping the index size in check by deleting those past that limit.
I haven't been able to come up with a query that would give me the Nth
document after aggregating by client and sorting by date. I don't necessarily need to do this in a single query, but what would be the recommended approach for this?
Thank you!