Inline script in an update or _reindex call

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?

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

uhh, yes apparently so :slight_smile:

learned something new..

Great to hear! :smiley: