# Remove duplicate values across buckets

**URL:** <https://discuss.elastic.co/t/remove-duplicate-values-across-buckets/132514>\
**Category:** Elasticsearch\
**Created:** [May 18, 2018, 4:15pm UTC](https://discuss.elastic.co/t/remove-duplicate-values-across-buckets/132514 "2018-05-18T16:15:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monte\_A](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Monte\_A](https://discuss.elastic.co/u/Monte_A)\
**Post date:** [May 18, 2018, 4:15pm UTC](https://discuss.elastic.co/t/remove-duplicate-values-across-buckets/132514/1 "2018-05-18T16:15:38Z")

</div>

Hi All,

Is there a way to get unique values across all buckets?

```
{"user-id":"1", "user-name":"A", "user-age":"30", "update-date":"2018-01-01"}
{"user-id":"1", "user-name":"A", "user-age":"30", "update-date":"2018-02-01"}
{"user-id":"2", "user-name":"B", "user-age":"30", "update-date":"2018-01-01"}
{"user-id":"2", "user-name":"B", "user-age":"30", "update-date":"2018-02-01"}

```

The result I would like to get is two buckets based on 'user-name' and 'user-age' with the following records

```
{"user-id":"1", "user-name":"A", "user-age":"30", "update-date":"2018-02-01"}
{"user-id":"2", "user-name":"B", "user-age":"30", "update-date":"2018-02-01"}

```

Is it possible?

Thanks

---

<div class="post-metadata">

**Author:** ![psramkumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/psramkumar/32/31393_2.png) [@psramkumar](https://discuss.elastic.co/u/psramkumar)\
**Post date:** [May 19, 2018, 2:12am UTC](https://discuss.elastic.co/t/remove-duplicate-values-across-buckets/132514/2 "2018-05-19T02:12:56Z")

</div>

use aggregation with scripted\_metric..,

[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html)

---

<div class="post-metadata">

**Author:** ![Monte\_A](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Monte\_A](https://discuss.elastic.co/u/Monte_A)\
**Post date:** [May 20, 2018, 7:36pm UTC](https://discuss.elastic.co/t/remove-duplicate-values-across-buckets/132514/3 "2018-05-20T19:36:36Z")

</div>

Thank you

---

<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:** [June 17, 2018, 7:36pm UTC](https://discuss.elastic.co/t/remove-duplicate-values-across-buckets/132514/4 "2018-06-17T19:36:37Z")

</div>

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