# Nested Aggregation to just get some nested type without aggregatioon

**URL:** <https://discuss.elastic.co/t/nested-aggregation-to-just-get-some-nested-type-without-aggregatioon/324588>\
**Category:** Elasticsearch\
**Created:** [February 3, 2023, 1:59am UTC](https://discuss.elastic.co/t/nested-aggregation-to-just-get-some-nested-type-without-aggregatioon/324588 "2023-02-03T01:59:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Yu1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jason_yu1/32/108602_2.png) [@Jason\_Yu1](https://discuss.elastic.co/u/Jason_Yu1)\
**Post date:** [February 3, 2023, 1:59am UTC](https://discuss.elastic.co/t/nested-aggregation-to-just-get-some-nested-type-without-aggregatioon/324588/1 "2023-02-03T01:59:06Z")

</div>

I am not sure if is that possible. We have a set of documents with the same testId, and each set of those docs, always only have 1 of them has the `frames` nested type.  
So I want to do the aggression with the data, there is no issue for that but I want to somehow get the frames as well.

I can do that for

```auto
PUT test_nested_agg
{
  "mappings": {
    "properties": {
      "testId": {"type": "keyword"},
     "frames": {
        "type":"nested",
        "properties": {
          "name": { "type": "keyword" },
          "length": { "type": "long"}
        }
      },
      /* other properties*/
    }
  }
}

```

Example of my current query

```auto

{

    "query": {
        "bool": {
            "must": [{ "terms": { "testId": [123]}}]
        }
    },
    "_source": ["frames"],
    "aggregations": {
        "histogramTime": {
            "histogram": {
                "field": "timesteamp",
                "interval": 10,
                "order": {
                    "_key": "asc"
                },
                "min_doc_count": 0,
                "extended_bounds": {
                    "min": 1674608461,
                    "max": 1674694861
                }
            },
            "aggregations": {
                 "numOfIssues": {
                    "value_count": {
                        "field": "issue"
                    }
                }
               /* other aggregations*/
            }
        }
    }
}

```

---

<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:** [March 3, 2023, 1:59am UTC](https://discuss.elastic.co/t/nested-aggregation-to-just-get-some-nested-type-without-aggregatioon/324588/2 "2023-03-03T01:59:49Z")

</div>

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