# How to deduplicate and perform aggregations using single Elastic search query?

**URL:** <https://discuss.elastic.co/t/how-to-deduplicate-and-perform-aggregations-using-single-elastic-search-query/229650>\
**Category:** Elasticsearch\
**Created:** [April 24, 2020, 12:15pm UTC](https://discuss.elastic.co/t/how-to-deduplicate-and-perform-aggregations-using-single-elastic-search-query/229650 "2020-04-24T12:15:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhaveshpatel640](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhaveshpatel640/32/67046_2.png) [@bhaveshpatel640](https://discuss.elastic.co/u/bhaveshpatel640)\
**Post date:** [April 24, 2020, 12:15pm UTC](https://discuss.elastic.co/t/how-to-deduplicate-and-perform-aggregations-using-single-elastic-search-query/229650/1 "2020-04-24T12:15:38Z")

</div>

I have an index where employee details data is stored.

I have feedback field per employee integer values (0-10).

I want to get the count of feedback, avg rating of the feedbacks and avg rating per employee of the feedback.

The problem here is:

So I have two or more same documents (duplicate) in an ES index (using employee id and one feedback identifier, we can distinguish the records),

I want to do avg and count on some fields with only one document to be considered using ES query only

PS: We cannot remove duplications from the index.

> <https://stackoverflow.com/questions/61407178/how-to-deduplicate-and-perform-aggregations-using-single-elastic-search-query>

---

<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 22, 2020, 12:15pm UTC](https://discuss.elastic.co/t/how-to-deduplicate-and-perform-aggregations-using-single-elastic-search-query/229650/2 "2020-05-22T12:15:42Z")

</div>

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