# Problem with script aggregation

**URL:** <https://discuss.elastic.co/t/problem-with-script-aggregation/187770>\
**Category:** Kibana\
**Created:** [June 27, 2019, 7:10am UTC](https://discuss.elastic.co/t/problem-with-script-aggregation/187770 "2019-06-27T07:10:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aurelien1212](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@aurelien1212](https://discuss.elastic.co/u/aurelien1212)\
**Post date:** [June 27, 2019, 7:10am UTC](https://discuss.elastic.co/t/problem-with-script-aggregation/187770/1 "2019-06-27T07:10:33Z")

</div>

Hi all,

I got an exception while trying to use a script aggregation in Kibana using the json input:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/d/8d51e5f6edcb983c170df22f3e852221c6ad0459.png)

I can reproduce the error in Dev Tools when I specify both the field and the script for the same aggregation:

> GET online/\_search?size=0  
> {  
> "aggs": {  
> "tag": {  
> "terms": {  
> "field": "tag.keyword",  
> "script": {  
> "source": "doc['tag.keyword']",  
> "lang": "painless"  
> }  
> }  
> }  
> }  
> }

If I remove the field attribute, everything is working perfectly:

> GET online/\_search?size=0  
> {  
> "aggs": {  
> "tag": {  
> "terms": {  
> "script": {  
> "source": "doc['tag.keyword']",  
> "lang": "painless"  
> }  
> }  
> }  
> }  
> }

But Kibana does not allow me to use JSON input without specifying a field in aggregation.

I am using version 5.6.7.

Thank you for you help,

Aurelien

---

<div class="post-metadata">

**Author:** ![aurelien1212](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@aurelien1212](https://discuss.elastic.co/u/aurelien1212)\
**Post date:** [June 27, 2019, 2:41pm UTC](https://discuss.elastic.co/t/problem-with-script-aggregation/187770/2 "2019-06-27T14:41:07Z")

</div>

I installed locally last version of ES and Kibana (7.2) and it is working as expected on this version. So I think best way to solve my issue is to upgrade...

---

<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:** [July 25, 2019, 2:41pm UTC](https://discuss.elastic.co/t/problem-with-script-aggregation/187770/3 "2019-07-25T14:41:12Z")

</div>

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