# Inline script in an update or \_reindex call

**URL:** <https://discuss.elastic.co/t/inline-script-in-an-update-or--reindex-call/60336>\
**Category:** Elasticsearch\
**Created:** [September 13, 2016, 1:45am UTC](https://discuss.elastic.co/t/inline-script-in-an-update-or--reindex-call/60336 "2016-09-13T01:45:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronchalant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ronchalant/32/3611_2.png) [@ronchalant](https://discuss.elastic.co/u/ronchalant)\
**Post date:** [September 13, 2016, 1:45am UTC](https://discuss.elastic.co/t/inline-script-in-an-update-or--reindex-call/60336/1 "2016-09-13T01:45:17Z")

</div>

I think I'm testing the limits of what can be done in a reindex/update w/ an inline script, but I figured I'd ask.

One of the properties I've mapped in the past is a serialized hash w/ string keys & values. The hash is largely dynamic - the source data is external. Think along the lines of if you were to index request headers for a webserver, and you might encounter custom X-headers or something along those lines that you want to have indexed.

I have a large number of these already indexed, and it's become necessary to have the values of the hash be indexed into two separate variables, one raw ("index": "not\_analyzed") and one standard analyzed.

So the new indexed documents would look something along the lines of:

```
"headers": {
   "key_1": { 
    "raw": "my value",
    "analyzed": "my value"
   },
   "key_2": { 
    "raw": "my other value",
    "analyzed": "my other value"
   }
}

```

but the objects in the existing index just look like:

```
"headers": {
   "key_1": "my value",
   "key_2": "my other value"
   }
}

```

Is this something I'm going to have to handle separately outside of Elastic? Or is the \_reindex and/or update API capable of this level of transformation and I'm just missing how?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 13, 2016, 9:45am UTC](https://discuss.elastic.co/t/inline-script-in-an-update-or--reindex-call/60336/2 "2016-09-13T09:45:41Z")

</div>

Wouldn't setting a new index with a multifield mapping handle this?

---

<div class="post-metadata">

**Author:** ![ronchalant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ronchalant/32/3611_2.png) [@ronchalant](https://discuss.elastic.co/u/ronchalant)\
**Post date:** [September 13, 2016, 11:38am UTC](https://discuss.elastic.co/t/inline-script-in-an-update-or--reindex-call/60336/3 "2016-09-13T11:38:08Z")

</div>

uhh, yes apparently so 🙂

learned something new..

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 13, 2016, 9:05pm UTC](https://discuss.elastic.co/t/inline-script-in-an-update-or--reindex-call/60336/4 "2016-09-13T21:05:23Z")

</div>

Great to hear! 😃

---

<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 5, 2017, 10:20pm UTC](https://discuss.elastic.co/t/inline-script-in-an-update-or--reindex-call/60336/5 "2017-07-05T22:20:30Z")

</div>


