[ES 7.0] Filtering nested aggregation - how do I do it?

I have tried to filter out all the objects/documents in the nested objected called jobs_won, but I can't seem to get it to work. I have been googling for days :sweat_smile:

How do I filter out certain objects/documents based on the term "r_published": 1

{
    "aggs": {
        "jobs_won": {
            "nested": {
                "path": "jobs_won"
            },
            "aggs": {
                "total_jobs_won": {
                    "terms": {
                        "field": "jobs_won.b_id"
                    }
                }
            }
        }
    }
}

An example of how a job_won object/document looks like. This object is nested:

{
    "r_score": 5,
    "r_published": 1,
    "b_id": 422133
}

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