Select documents by a property of the most recent subdocument

I'm working in a decoupled app, responsible for making calls to an ElasticSearch backend whose schema I don't control. The hits I get back (which are analogous to forum posts) look like this:

{
    title: string,
    author: string,
    comments: [
        {
            date: Date,
            author: string,
            body: string,
        },
        ...
    ],
}

I want to get back all posts whose most recent comment was written by a specific author. I have searched quite a bit and have not been able to come up with a way to do this with an ElasticSearch query. Could someone enlighten me? Thanks!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.