# Required Elastic Query with having Clause in Aggregation

**URL:** <https://discuss.elastic.co/t/required-elastic-query-with-having-clause-in-aggregation/328920>\
**Category:** Elasticsearch\
**Created:** [March 30, 2023, 9:48am UTC](https://discuss.elastic.co/t/required-elastic-query-with-having-clause-in-aggregation/328920 "2023-03-30T09:48:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sunny\_Gupta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunny_gupta/32/119200_2.png) [@Sunny\_Gupta](https://discuss.elastic.co/u/Sunny_Gupta)\
**Post date:** [March 30, 2023, 9:48am UTC](https://discuss.elastic.co/t/required-elastic-query-with-having-clause-in-aggregation/328920/1 "2023-03-30T09:48:05Z")

</div>

If Have One index having records with Properties Email and Event  
We have different Events like Submitted, Delivered,Bounce etc.  
I want to Get those record that available in Submitted only.  
Means If any Email has to delivered or Bounce then it's not shows in the result.  
Example:  
Email Event  
[Sunny@x.com](mailto:Sunny@x.com) Delivered  
[Sunny@x.com](mailto:Sunny@x.com) Submitted  
[pp@x.com](mailto:pp@x.com) Submitted  
If these are the record available in the index then It return on [pp@x.com](mailto:pp@x.com) because it has only Submitted Record.

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [March 30, 2023, 9:57am UTC](https://discuss.elastic.co/t/required-elastic-query-with-having-clause-in-aggregation/328920/2 "2023-03-30T09:57:46Z")

</div>

Hi @Sunny_Gupta

The [Term Query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html) can be used to filter docs with event type Submitted.

---

<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:** [April 27, 2023, 9:58am UTC](https://discuss.elastic.co/t/required-elastic-query-with-having-clause-in-aggregation/328920/3 "2023-04-27T09:58:31Z")

</div>

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