# Find sum of values in deduplicated docs

**URL:** <https://discuss.elastic.co/t/find-sum-of-values-in-deduplicated-docs/32963>\
**Category:** Elasticsearch\
**Created:** [October 26, 2015, 7:54am UTC](https://discuss.elastic.co/t/find-sum-of-values-in-deduplicated-docs/32963 "2015-10-26T07:54:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![altvec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/altvec/32/5375_2.png) [@altvec](https://discuss.elastic.co/u/altvec)\
**Post date:** [October 26, 2015, 7:54am UTC](https://discuss.elastic.co/t/find-sum-of-values-in-deduplicated-docs/32963/1 "2015-10-26T07:54:02Z")

</div>

Hi,

I have an index with a lot of documents, some of them contains the same value for the same field, for example:

doc1:

```
{
    "play_begin": "2015-10-26",
    "play_end": "2015-10-26",
    "price": 5,
    "name": "test",
    "account": 826719,
    "session_id": 1437636558,
    "service_begin": "2015-10-26",
    "service_end": "2015-10-29"
}

```

doc2:

```
{
    "play_begin": "2015-10-27",
    "play_end": "2015-10-27",
    "price": 5,
    "name": "test",
    "account": 826719,
    "session_id": 1437636558,
    "service_begin": "2015-10-26",
    "service_end": "2015-10-29"
}

```

doc3:

```
{
    "play_begin": "2015-10-27",
    "play_end": "2015-10-27",
    "price": 10,
    "name": "test2",
    "account": 826719,
    "session_id": 1437636558,
    "service_begin": "2015-10-26",
    "service_end": "2015-10-29"
}

```

I need to deduplicate docs by fields 'account', 'service\_begin', 'service\_end', 'name' and find sum of values in the 'price' field. What's the proper way to complete this? Is it possible?

Thanks to anyone that replies.

---

<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:42pm UTC](https://discuss.elastic.co/t/find-sum-of-values-in-deduplicated-docs/32963/2 "2017-07-05T23:42:43Z")

</div>


