# Help in query approach needed

**URL:** <https://discuss.elastic.co/t/help-in-query-approach-needed/126863>\
**Category:** Elasticsearch\
**Created:** [April 5, 2018, 7:05am UTC](https://discuss.elastic.co/t/help-in-query-approach-needed/126863 "2018-04-05T07:05:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SKumarMN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skumarmn/32/27537_2.png) [@SKumarMN](https://discuss.elastic.co/u/SKumarMN)\
**Post date:** [April 5, 2018, 7:05am UTC](https://discuss.elastic.co/t/help-in-query-approach-needed/126863/1 "2018-04-05T07:05:12Z")

</div>

Hi All,

I have a sample data in my index as below

{ "id": 1, "doc": "d1" }  
{ "id": 2, "doc": "d1", "event": "e1" }  
{ "id": 3, "doc": "d1", "event": "e2" }  
{ "id": 4, "doc": "d2", "event": "e1" }  
{ "id": 5, "doc": "d2", "event": "e3" }  
{ "id": 6, "doc": "d3" }

I need to find out the count of unique events + count of docs which has no events associated with it in any documents. Just to explain further the answer expected is 4 where there are three unique events e1,e2,e3 and one document d3 which has no event associated with it. Here document with id1 which has d1 as "doc" value should not be considered as d1 has some event associated with it some other docs like doc with id3, id2

---

<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:** [May 3, 2018, 7:05am UTC](https://discuss.elastic.co/t/help-in-query-approach-needed/126863/2 "2018-05-03T07:05:30Z")

</div>

Closed on May 3, 2018, 7:05am UTC

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