# How to aggregate non-nested fields in a nested aggregation?

**URL:** <https://discuss.elastic.co/t/how-to-aggregate-non-nested-fields-in-a-nested-aggregation/351044>\
**Category:** Elasticsearch\
**Tags:** language-clients, aggregations\
**Created:** [January 15, 2024, 1:33am UTC](https://discuss.elastic.co/t/how-to-aggregate-non-nested-fields-in-a-nested-aggregation/351044 "2024-01-15T01:33:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chanseok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chanseok/32/130800_2.png) [@Chanseok](https://discuss.elastic.co/u/Chanseok)\
**Post date:** [January 15, 2024, 1:33am UTC](https://discuss.elastic.co/t/how-to-aggregate-non-nested-fields-in-a-nested-aggregation/351044/1 "2024-01-15T01:33:05Z")

</div>

The prices.adult field in "lowest\_price" is non-nested fields in a nest.

The current "lowest\_price" value is null.  
How can I get that value?

// Aggregation code

```auto
  "aggs": {
    "destination": {
      "nested": {
        "path": "locations"
      },
      "aggs": {
        "destination_filter": {
          "filter": {
            "terms": {
              "locations.id": [
                479
              ]
            }
          },
          "aggs": {
            "count": {
              "terms": {
                "field": "locations.name"
              },
              "aggs": {
                "lowest_price": {
                  "min": {
                    "field": "prices.adult"
                  }
                }
              }
            }
          }
        }
      }
    }
  }

```

---

<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:** [February 12, 2024, 1:34am UTC](https://discuss.elastic.co/t/how-to-aggregate-non-nested-fields-in-a-nested-aggregation/351044/2 "2024-02-12T01:34:02Z")

</div>

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