# Scripted filed is not working

**URL:** <https://discuss.elastic.co/t/scripted-filed-is-not-working/85243>\
**Category:** Kibana\
**Created:** [May 10, 2017, 12:31pm UTC](https://discuss.elastic.co/t/scripted-filed-is-not-working/85243 "2017-05-10T12:31:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![udaykirankona](https://avatars.discourse-cdn.com/v4/letter/u/ac91a4/32.png) [@udaykirankona](https://discuss.elastic.co/u/udaykirankona)\
**Post date:** [May 10, 2017, 12:31pm UTC](https://discuss.elastic.co/t/scripted-filed-is-not-working/85243/1 "2017-05-10T12:31:41Z")

</div>

HI,

I created scripted field on numeric field with following expression and painless script,

**doc['field'].sum()**

but its not working.  
I am using ELK - 5.4.0 version

its not giving any error, but values always are 1's or 0's  
Can somebody please help with this.

Also Is there any way to calculate count like **doc['field'].count()**.

Thanks in advance

Uday.K

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [May 10, 2017, 2:38pm UTC](https://discuss.elastic.co/t/scripted-filed-is-not-working/85243/2 "2017-05-10T14:38:21Z")

</div>

@udaykirankona

Where did you find a reference to those `sum` and `count` methods?

In Kibana, scripted fields transform one or more document values into a new value (on a per document basis).

To get started, see:

- [https://www.elastic.co/guide/en/kibana/current/scripted-fields.html](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html)
- [https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-painless.html](https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-painless.html)

---

<div class="post-metadata">

**Author:** ![udaykirankona](https://avatars.discourse-cdn.com/v4/letter/u/ac91a4/32.png) [@udaykirankona](https://discuss.elastic.co/u/udaykirankona)\
**Post date:** [May 10, 2017, 7:01pm UTC](https://discuss.elastic.co/t/scripted-filed-is-not-working/85243/3 "2017-05-10T19:01:43Z")

</div>

Hi thomas,

Please look into the following link,

[https://www.elastic.co/guide/en/elasticsearch/reference/5.4/modules-scripting-expression.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/modules-scripting-expression.html)

Thanks,  
Uday.K

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [May 10, 2017, 9:55pm UTC](https://discuss.elastic.co/t/scripted-filed-is-not-working/85243/4 "2017-05-10T21:55:30Z")

</div>

That link seems to be for array-values for a document, not over all the documents in the index.

---

<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:** [June 7, 2017, 10:08pm UTC](https://discuss.elastic.co/t/scripted-filed-is-not-working/85243/5 "2017-06-07T22:08:57Z")

</div>

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