# Scripting

**URL:** <https://discuss.elastic.co/t/scripting/123411>\
**Category:** Elasticsearch\
**Created:** [March 11, 2018, 6:15am UTC](https://discuss.elastic.co/t/scripting/123411 "2018-03-11T06:15:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Errors](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Errors](https://discuss.elastic.co/u/Errors)\
**Post date:** [March 11, 2018, 6:15am UTC](https://discuss.elastic.co/t/scripting/123411/1 "2018-03-11T06:15:11Z")

</div>

I've written the following script and am running it using dev tools

 ![asdfsafsa](https://us1.discourse-cdn.com/elastic/original/3X/b/c/bc0697b900954bb52d78b878e17138f05b0a7502.PNG)  
The first time I ran it, the field "result" said "created". As you can see from the screenshot, I've run this code a couple of times. Reason being, When I go back onto the 'discover' tab in kibana, there is no new field created called 'full\_name'. I dont understand what's going on here, where is this field now and how do I get it to display? I would like to use it to later in Kibana...  
If my approach is wrong, whats another way to create a new field and copy over the value of an existing field into that new field?  
I have triped the 'copy\_to' approach like so:

```
PUT somelistcopy/_mapping/doc
{
  "properties": {
    "parsed.FIRST_NAME": {
      "type": "text",
      "copy_to": "full_name" 
    },
    "full_name": {
      "type": "text"
    }
  }
}

```

But it doesn't actually create a new field in the mapping which you can use later in Kibana to visualise anything...

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [March 11, 2018, 3:50pm UTC](https://discuss.elastic.co/t/scripting/123411/2 "2018-03-11T15:50:26Z")

</div>

Your example PUT request is indexing the entire json there. Are you trying to do an [update by query](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html)?

---

<div class="post-metadata">

**Author:** ![Errors](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Errors](https://discuss.elastic.co/u/Errors)\
**Post date:** [March 13, 2018, 7:05am UTC](https://discuss.elastic.co/t/scripting/123411/3 "2018-03-13T07:05:39Z")

</div>

Uhh possibly,  
If I were to do an update by query, would i be able to use the new variable in Kibana?

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [March 13, 2018, 6:51pm UTC](https://discuss.elastic.co/t/scripting/123411/4 "2018-03-13T18:51:04Z")

</div>

An update by query would reindex your documents, allowing you to add the new field in with the update. Kibana can then do anything you can normally do with fields in elasticsearch. Note this is _not_ kibana scripted fields.

---

<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 10, 2018, 6:51pm UTC](https://discuss.elastic.co/t/scripting/123411/5 "2018-04-10T18:51:47Z")

</div>

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