Pipeline aggregation for selecting the documents

Hello,

I have the documents in the following form:

  {
    "_type": "...",
    "_id": "...",
    "_source": {
      "duration": 1000,
      "version": "<some version>",
      "desc": "<some text>",
      "timestamp": "<date>"
    }
  }

In a query docs are aggregated by type and desc, filtered by version and in a sub aggregation percentiles are calculated for the 'duration' field. In YAML it looks like this:

aggs:
    byType:
        terms: { size: 10000, field: "_type" }
        aggs:
            byDesc:
                terms: { size: 10000, field: "desc" }
                aggs:
                    a:
                        filter : { term: { version: "<version a>" } }
                        aggs:
                            p: { percentiles: { field: "duration", percents: [..., 99] } }
                    b:
                        filter : { term: { version: "<version b>" } }
                        aggs:
                            p: { percentiles: { field: "duration", percents: [..., 99] } }

now, I would like to select some documents for both versions which fall into the 99% bucket, in other words, find a doc which has 'duration' value greater or equal to the 99th percentile. Looking at the documentation I failed to find such option. I would really like to avoid doing N+1 requests to fetch the data I need.
Thanks!

up, anyone?!

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