# ES Scripting - How to access a multi field value

**URL:** <https://discuss.elastic.co/t/es-scripting-how-to-access-a-multi-field-value/39503>\
**Category:** Kibana\
**Created:** [January 19, 2016, 7:00am UTC](https://discuss.elastic.co/t/es-scripting-how-to-access-a-multi-field-value/39503 "2016-01-19T07:00:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![britto1981](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@britto1981](https://discuss.elastic.co/u/britto1981)\
**Post date:** [January 19, 2016, 7:00am UTC](https://discuss.elastic.co/t/es-scripting-how-to-access-a-multi-field-value/39503/1 "2016-01-19T07:00:16Z")

</div>

I have a sub field named "util" defined in the ES mappings as shown below:

```
      "metric_value_number": {
        "type": "long",
        "fields": {
          "util": {
            "type": "double"
          }
        }
      }

```

In the Kibana UI, I have created a new scriping field named "CPU\_UTL\_PERCNT" and also added the following script against the field for calculation:  
doc['metric\_value\_number.util'].value

Then I selected the field to perform a search. I am getting the following error now:  
**Discover: Field [metric\_value\_number.util] used in expression does not exist in mappings**

Could any one please check it up and advice me on how to access the util field based on the above mapping?

---

<div class="post-metadata">

**Author:** ![kaib](https://avatars.discourse-cdn.com/v4/letter/k/f14d63/32.png) [@kaib](https://discuss.elastic.co/u/kaib)\
**Post date:** [January 19, 2016, 11:43am UTC](https://discuss.elastic.co/t/es-scripting-how-to-access-a-multi-field-value/39503/2 "2016-01-19T11:43:12Z")

</div>

shouldn't it be

> metric\_value\_number.fields.util

??

---

<div class="post-metadata">

**Author:** ![britto1981](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@britto1981](https://discuss.elastic.co/u/britto1981)\
**Post date:** [January 19, 2016, 12:17pm UTC](https://discuss.elastic.co/t/es-scripting-how-to-access-a-multi-field-value/39503/3 "2016-01-19T12:17:11Z")

</div>

Thanks for your reply. But, It did not work. Now, I am getting the following error now:  
**Discover: Field [metric\_value\_number.fields.util] used in expression does not exist in mappings**

I have received the following in the error stack trace:  
"Error during search with inline script [doc['metric\_value\_number.fields.util'].value] using lang [expression]","caused\_by":{"type":"expression\_script\_compilation\_exception","reason":"Field [metric\_value\_number.fields.util] used in expression does not exist in mappings"}}}]}}

---

<div class="post-metadata">

**Author:** ![britto1981](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@britto1981](https://discuss.elastic.co/u/britto1981)\
**Post date:** [January 19, 2016, 12:20pm UTC](https://discuss.elastic.co/t/es-scripting-how-to-access-a-multi-field-value/39503/4 "2016-01-19T12:20:00Z")

</div>

Even I tried with the following syntax: **metric\_value\_number.fields[0].util**

But, I have received the same error as follows:  
**Discover: Field [metric\_value\_number.fields[0].util] used in expression does not exist in mappings**

---

<div class="post-metadata">

**Author:** ![britto1981](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@britto1981](https://discuss.elastic.co/u/britto1981)\
**Post date:** [February 1, 2016, 10:55am UTC](https://discuss.elastic.co/t/es-scripting-how-to-access-a-multi-field-value/39503/5 "2016-02-01T10:55:36Z")

</div>

Any update on this, please?

---

<div class="post-metadata">

**Author:** ![stormpython](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stormpython/32/7190_2.png) [@stormpython](https://discuss.elastic.co/u/stormpython)\
**Post date:** [February 1, 2016, 7:23pm UTC](https://discuss.elastic.co/t/es-scripting-how-to-access-a-multi-field-value/39503/6 "2016-02-01T19:23:24Z")

</div>

britto1981,

It seems you are attempting to use a `mult_field` type but you are defining it as a long. Not sure why in this case you are using a multi\_field. Why not simply use:

```auto
"metric_value_number": { "type": "long" }.

```

If you are using a multi-field type, it should look like the following:

```auto
"metric_value_number": {
    "type": "multi_field",
    "fields" : {
        "util" : { "type" : "double" }
    }
}

```

Try doing that and let me know if that works.

---

<div class="post-metadata">

**Author:** ![stormpython](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stormpython/32/7190_2.png) [@stormpython](https://discuss.elastic.co/u/stormpython)\
**Post date:** [February 1, 2016, 7:40pm UTC](https://discuss.elastic.co/t/es-scripting-how-to-access-a-multi-field-value/39503/7 "2016-02-01T19:40:27Z")

</div>

Please ignore the previous comment. Bad advice since `multi_field` is dead.

Did you try refreshing your Kibana 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:** [July 6, 2017, 2:03pm UTC](https://discuss.elastic.co/t/es-scripting-how-to-access-a-multi-field-value/39503/8 "2017-07-06T14:03:36Z")

</div>

Closed on July 6, 2017, 2:03pm UTC


