How can we make aggregation query on document?

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 ?

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.