# What's the new FilterAggregator in the java client 8

**URL:** https://discuss.elastic.co/t/whats-the-new-filteraggregator-in-the-java-client-8/349737
**Category:** Elasticsearch
**Created:** [December 20, 2023, 3:50pm UTC](https://discuss.elastic.co/t/whats-the-new-filteraggregator-in-the-java-client-8/349737 "2023-12-20T15:50:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Darth\_vader\_22](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/darth_vader_22/32/130197_2.png) [@Darth\_vader\_22](https://discuss.elastic.co/u/Darth_vader_22)
#### Post date: [December 20, 2023, 3:50pm UTC](https://discuss.elastic.co/t/whats-the-new-filteraggregator-in-the-java-client-8/349737/1 "2023-12-20T15:50:37Z")

</div>

hello guys ,  
i'm having hard times trying to find a way to create a FilterAggregationBuilder in the new java client 8.11 , if anyone could point me te the solution i'll be grateful

```auto
        FiltersAggregationBuilder aggregation = AggregationBuilders
                .filters("agg_name",
                        new FiltersAggregator.KeyedFilter("filter_one", authenticationAttemptQueryBuilder),
                        new FiltersAggregator.KeyedFilter("filter_two", failedAuthenticationAttemptQueryBuilder))
                .subAggregation(aggregationByStructureId);

```

---

<div class="post-metadata">

### Author: ![Darth\_vader\_22](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/darth_vader_22/32/130197_2.png) [@Darth\_vader\_22](https://discuss.elastic.co/u/Darth_vader_22)
#### Post date: [December 21, 2023, 9:35am UTC](https://discuss.elastic.co/t/whats-the-new-filteraggregator-in-the-java-client-8/349737/2 "2023-12-21T09:35:22Z")

</div>

Hello again ! if anyone has insights or can point me towards relevent resources , it would be appreciated

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [December 21, 2023, 10:47am UTC](https://discuss.elastic.co/t/whats-the-new-filteraggregator-in-the-java-client-8/349737/3 "2023-12-21T10:47:41Z")

</div>

I think it should be something like this:

```auto
client.search(sr -> sr.aggregations("agg_name",
        a -> a.filters(f ->
            f.filters(fr -> fr
                .keyed(Map.of(
                    "filter_one", Query.of(q -> q.term(tq -> tq.field("foo").value("bar"))),
                    "filter_two", Query.of(q -> q.term(tq -> tq.field("foo").value("baz")))
                ))))), Void.class);

```

Adding some information about this forum policy:

> Please be patient in waiting for responses to your question and refrain from pinging multiple times asking for a response or opening multiple topics for the same question. This is a community forum, it may take time for someone to reply to your question. For more information please refer to the [Community Code of Conduct](https://www.elastic.co/community/codeofconduct) specifically the section "Be patient". Also, please refrain from pinging folks directly, this is a forum and anyone that participates might be able to assist you.
> 
> If you are in need of a service with an SLA that covers response times for questions then you may want to consider talking to us about a [subscription](https://www.elastic.co/subscriptions).
> 
> It's fine to answer on your own thread after 2 or 3 days (not including weekends) if you don't have an answer.

---

<div class="post-metadata">

### Author: ![Darth\_vader\_22](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/darth_vader_22/32/130197_2.png) [@Darth\_vader\_22](https://discuss.elastic.co/u/Darth_vader_22)
#### Post date: [December 22, 2023, 8:36am UTC](https://discuss.elastic.co/t/whats-the-new-filteraggregator-in-the-java-client-8/349737/4 "2023-12-22T08:36:24Z")

</div>

Thank you , that helped

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 19, 2024, 8:37am UTC](https://discuss.elastic.co/t/whats-the-new-filteraggregator-in-the-java-client-8/349737/5 "2024-01-19T08:37:16Z")

</div>

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