# How to convert scripted field to runtime field - KIbana \_doc compile error

**URL:** <https://discuss.elastic.co/t/how-to-convert-scripted-field-to-runtime-field-kibana-doc-compile-error/299391>\
**Category:** Elasticsearch\
**Tags:** painless, runtime-fields\
**Created:** [March 11, 2022, 3:18am UTC](https://discuss.elastic.co/t/how-to-convert-scripted-field-to-runtime-field-kibana-doc-compile-error/299391 "2022-03-11T03:18:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rugenl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rugenl/32/12887_2.png) [@rugenl](https://discuss.elastic.co/u/rugenl)\
**Post date:** [March 11, 2022, 3:18am UTC](https://discuss.elastic.co/t/how-to-convert-scripted-field-to-runtime-field-kibana-doc-compile-error/299391/1 "2022-03-11T03:18:11Z")

</div>

Some time ago I fought scripted fields in this post: [Painless doc values; how to reference grouped fields](https://discuss.elastic.co/t/painless-doc-values-how-to-reference-grouped-fields/276588)

Now scripted fields are deprecated and I'm trying to convert this to a runtime field. I'm using the KIbana component index to create a runtime field. I copied the script over as is and it won't create. I dropped to just the first line, getting the same error:

```auto
if (doc[winlog.user_data.FilePath'].size() == 0) {
    return ''
}

```

Results in a pretty useless error:

```auto
Unable to create component template
Failed to parse mapping [_doc]: compile error

```

Any ideas? Has anyone seen any examples of runtime fields referencing grouped fields? I don't see any doc in the Kibana guide for the entire Stack Management section.

Thanks

---

<div class="post-metadata">

**Author:** ![rugenl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rugenl/32/12887_2.png) [@rugenl](https://discuss.elastic.co/u/rugenl)\
**Post date:** [March 11, 2022, 3:42am UTC](https://discuss.elastic.co/t/how-to-convert-scripted-field-to-runtime-field-kibana-doc-compile-error/299391/2 "2022-03-11T03:42:02Z")

</div>

I found some better doc: [Elastic Runtime Field example repository from elastic content share](https://elastic-content-share.eu/elastic-runtime-field-example-repository/)

Elastic's doc appeared to wrap the entire script in emit() but this doc shows more strategic and correct use of emit().

More trial and error... stay tuned.

---

<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:** [April 8, 2022, 3:42am UTC](https://discuss.elastic.co/t/how-to-convert-scripted-field-to-runtime-field-kibana-doc-compile-error/299391/3 "2022-04-08T03:42:45Z")

</div>

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