# COMPOSITE NESTED AGGREGATIONS

**URL:** https://discuss.elastic.co/t/composite-nested-aggregations/316013
**Category:** Elasticsearch
**Created:** [October 6, 2022, 9:42pm UTC](https://discuss.elastic.co/t/composite-nested-aggregations/316013 "2022-10-06T21:42:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Vinicius\_Serafim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinicius_serafim/32/102170_2.png) [@Vinicius\_Serafim](https://discuss.elastic.co/u/Vinicius_Serafim)
#### Post date: [October 6, 2022, 9:42pm UTC](https://discuss.elastic.co/t/composite-nested-aggregations/316013/1 "2022-10-06T21:42:12Z")

</div>

Hi, i hope that someone can help me.

Supose that i have the following mapping to my index:

```auto
PUT test-index
{
  "mappings": {
    "properties": {
      "nestedOBJField": {
        "type": "nested",
        "index": true
      },
       "keywordField": {
        "type": "keyword",
        "index": true
      }
    }
  }
}

```

It is possible to use the composite feature with nested fields?

It will be very handful if i can do something like this:

```auto
GET /test-index/_search
{
  "size": 0, 
  "aggs": {
    "TestAgg": {
      "composite": {
        "size": 10000,
        "sources": [
          {
            "keyWordFieldAgg": {
              "terms": {
                "field": "keyWordField"
              }
            },
           {
            "nestedFieldAgg": {
              "terms": {
                "field": "nestedOBJField.attribute"
              }
            }
          }
        ]
      }
    }
  }
}

```

But this aproach is returning a several number of errors.

I will appreciate a lot if someone can help

---

<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: [November 3, 2022, 9:42pm UTC](https://discuss.elastic.co/t/composite-nested-aggregations/316013/2 "2022-11-03T21:42:44Z")

</div>

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