# Error fields script in the Index Pattern

**URL:** <https://discuss.elastic.co/t/error-fields-script-in-the-index-pattern/321314>\
**Category:** Elasticsearch\
**Created:** [December 15, 2022, 1:39pm UTC](https://discuss.elastic.co/t/error-fields-script-in-the-index-pattern/321314 "2022-12-15T13:39:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpc29y](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@rpc29y](https://discuss.elastic.co/u/rpc29y)\
**Post date:** [December 15, 2022, 1:39pm UTC](https://discuss.elastic.co/t/error-fields-script-in-the-index-pattern/321314/1 "2022-12-15T13:39:13Z")

</div>

Hello.  
I have an elastic version 7.10 and in the Index Pattern of one of the indexes I have created a simple fields script:  
"doc['temperature']\* 10"  
Apparently the creation is correct, but I can't get to display the value of this field in a search or in Kibana.  
Indicating me:

An error occurred when loading data.

Show details of error  
Request error: search\_phase\_execution\_exception, all shards failed

Can you tell me where the problem may be?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [December 15, 2022, 2:25pm UTC](https://discuss.elastic.co/t/error-fields-script-in-the-index-pattern/321314/2 "2022-12-15T14:25:36Z")

</div>

Why are you using version 7.10? It is very old and EOL. I would recommend upgrading.

It is not entirely clear to me what you have done, so it would help if you could show exactly what you have done, the request you are sending when you get the error and the full error message.

---

<div class="post-metadata">

**Author:** ![rpc29y](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@rpc29y](https://discuss.elastic.co/u/rpc29y)\
**Post date:** [December 16, 2022, 7:31am UTC](https://discuss.elastic.co/t/error-fields-script-in-the-index-pattern/321314/3 "2022-12-16T07:31:35Z")

</div>

Hello.  
I have created an index with the following structure:  
{  
"mappings": {  
"properties": {  
"timestamp": {  
"type": "date"  
},  
"temperature": {  
"type": "long"  
},  
"voltage": {  
"type": "double"  
},  
"do not give": {  
"type": "keyword"  
},  
"voltage\_corrected": {  
"type": "double",  
"on\_script\_error": "fail",  
"script": {  
"source": "emit(doc['voltage'].value \* params['multiplier'])",  
"params": {  
multiplier: 4  
} }}}}}  
The index has been created successfully and I have inserted 7 documents:  
Status: open  
Document Count:7  
But the voltage\_corrected field from Discover or Dashboard is not available to me.  
The Number type fields that appear are:  
\_score  
mappings.properties.voltage\_corrected.script.params.multiplier  
timestamp  
voltage

but not "voltage\_corrected"

I understand that the script is wrong, right?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [December 16, 2022, 7:39am UTC](https://discuss.elastic.co/t/error-fields-script-in-the-index-pattern/321314/4 "2022-12-16T07:39:42Z")

</div>

Where did you find that in the docs?

Can you please show the mappings that were actually applied to the index you created?

It looks a bit like a [runtime field](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/runtime-mapping-fields.html), which was introduced in a later version. If you want to use runtime fields I would recommend you upgrade to at least version 7.17.

You have been able to specify [scripted fields in Kibana](https://www.elastic.co/guide/en/kibana/7.10/scripted-fields.html) for a while, but that is a Kibana internal construct that only works within Kibana and is not available in mappings or for external direct queries to Elasticsearch. You can get the same effect by using [script query clauses](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/query-dsl-script-query.html) but you have to include this in your queries and can not store these in mapping. This is what runtinme fields add in newer versions.

---

<div class="post-metadata">

**Author:** ![rpc29y](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@rpc29y](https://discuss.elastic.co/u/rpc29y)\
**Post date:** [January 9, 2023, 11:21am UTC](https://discuss.elastic.co/t/error-fields-script-in-the-index-pattern/321314/5 "2023-01-09T11:21:41Z")

</div>

OK Christian, let's see if we can solve it with the version update.  
Thanks

---

<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:** [February 6, 2023, 11:21am UTC](https://discuss.elastic.co/t/error-fields-script-in-the-index-pattern/321314/6 "2023-02-06T11:21:58Z")

</div>

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