# How to add aggregated field with \_source output field

**URL:** <https://discuss.elastic.co/t/how-to-add-aggregated-field-with-source-output-field/209439>\
**Category:** Elasticsearch\
**Created:** [November 26, 2019, 7:57am UTC](https://discuss.elastic.co/t/how-to-add-aggregated-field-with-source-output-field/209439 "2019-11-26T07:57:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rameshkr1994](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rameshkr1994/32/59029_2.png) [@rameshkr1994](https://discuss.elastic.co/u/rameshkr1994)\
**Post date:** [November 26, 2019, 7:57am UTC](https://discuss.elastic.co/t/how-to-add-aggregated-field-with-source-output-field/209439/1 "2019-11-26T07:57:02Z")

</div>

Dear All.

i having issue while adding the the aggregated fields with \_source field but key is not coming.

query 👎  
`GET healthecdemo/\_search  
{

```
"aggs": {
    "resulttest": {
        "terms": {
            "field": "healthrecordkey"
            
        }
    }
},
    "query": {
    "bool": {
        "must": [
            {
                "match": {
                    "firstname": "Firstname2467"
                }
            }
        ]
    }
},"_source": "firstname,key"

```

}`

> here key added from agg result and firstname is alredy there with this index.

> Output we want -  
> like : Firstname2467,121

Thanks  
HadoopHelp

---

<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:** [December 24, 2019, 7:57am UTC](https://discuss.elastic.co/t/how-to-add-aggregated-field-with-source-output-field/209439/2 "2019-12-24T07:57:09Z")

</div>

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