# Bucket Selector with Top Hits aggregation

**URL:** <https://discuss.elastic.co/t/bucket-selector-with-top-hits-aggregation/364847>\
**Category:** Elasticsearch\
**Tags:** eql-elastic-query-language\
**Created:** [August 13, 2024, 4:24pm UTC](https://discuss.elastic.co/t/bucket-selector-with-top-hits-aggregation/364847 "2024-08-13T16:24:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikg](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@erikg](https://discuss.elastic.co/u/erikg)\
**Post date:** [August 13, 2024, 4:24pm UTC](https://discuss.elastic.co/t/bucket-selector-with-top-hits-aggregation/364847/1 "2024-08-13T16:24:24Z")

</div>

Hello,

I have this query that is aggregates with top hits to retrieve the last doc.  
I want to use the bucket selector to filter for buckets that match a source field, event.outcome: "failure".

I am struggling with the bucket path:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/c/dc68cd049a7bd88c23c343d601e257620bda5c39.png)

This is how the aggregation looks without the bucket selector:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/8/f8646e782a1b596ac958ed063872c746b6f19815.png)
