# Bucket Aggregation with Distinct Source at multiple levels

**URL:** <https://discuss.elastic.co/t/bucket-aggregation-with-distinct-source-at-multiple-levels/267722>\
**Category:** Elasticsearch\
**Created:** [March 18, 2021, 9:27pm UTC](https://discuss.elastic.co/t/bucket-aggregation-with-distinct-source-at-multiple-levels/267722 "2021-03-18T21:27:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![F\_Doe\_FW](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f_doe_fw/32/77781_2.png) [@F\_Doe\_FW](https://discuss.elastic.co/u/F_Doe_FW)\
**Post date:** [March 18, 2021, 9:27pm UTC](https://discuss.elastic.co/t/bucket-aggregation-with-distinct-source-at-multiple-levels/267722/1 "2021-03-18T21:27:17Z")

</div>

Trying to see if I can pull out distinct values (keyword,float) on a bucket level.  
Top Hits will give me a lot of values that I have to discard.

```auto
{
  "size": 0,
  "query": {
    "bool": {
      "filter": {
        "bool": {
          "must": [
            {
              "range": {
                "week_starting": {
                  "gt": "now-24M/d",
                  "lte": "now/d"
                }
              }
            },
            {
              "terms": {
                "compkey": [
                  "asdasd"
                ]
              }
            }
          ]
        }
      }
    }
  },
  "aggs": {
    "group_by_content": {
      "terms": {
        "field": "destination_city",
        "size": 10000
      },
      --> need to get all the unique values for a field in the aggregation above , do the same thing multiple times<--
      "aggs": {
        "group_by_content": {
          "terms": {
            "field": "origin_city",
            "size": 10000
          }
        }
      }
    }
  }
}

```

Hoping there is a way to get these via some pathing or sibling type aggregation.

Thanks for the read!

---

<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:** [April 15, 2021, 9:27pm UTC](https://discuss.elastic.co/t/bucket-aggregation-with-distinct-source-at-multiple-levels/267722/2 "2021-04-15T21:27:30Z")

</div>

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