# How can we make aggregation query on document?

**URL:** <https://discuss.elastic.co/t/how-can-we-make-aggregation-query-on-document/26403>\
**Category:** Elasticsearch\
**Created:** [July 28, 2015, 9:30am UTC](https://discuss.elastic.co/t/how-can-we-make-aggregation-query-on-document/26403 "2015-07-28T09:30:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haresh\_Patel](https://avatars.discourse-cdn.com/v4/letter/h/c67d28/32.png) [@Haresh\_Patel](https://discuss.elastic.co/u/Haresh_Patel)\
**Post date:** [July 28, 2015, 9:30am UTC](https://discuss.elastic.co/t/how-can-we-make-aggregation-query-on-document/26403/1 "2015-07-28T09:30:20Z")

</div>

I am getting duplicate records while making query. I make a cardinality query but getting wrong document count.  
Is this possible like SQL I get distinct records ?

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [July 28, 2015, 9:40am UTC](https://discuss.elastic.co/t/how-can-we-make-aggregation-query-on-document/26403/2 "2015-07-28T09:40:31Z")

</div>

Elasticsearch does not support requesting unique documents. In order to do that, you would need to handle the deduplication step at indexing time, for instance by using a fingerprint of your documents as an id.

---

<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:** [July 5, 2017, 11:58pm UTC](https://discuss.elastic.co/t/how-can-we-make-aggregation-query-on-document/26403/3 "2017-07-05T23:58:39Z")

</div>


