I have a document with the field "name_servers" and "past_name_servers". If I have the following:
script_type => "inline"
script => '
ctx._source.name_servers = "%{name_servers}";
ctx._source.past_name_servers.add("%{name_servers}");
'
"past_name_servers" is properly updated and the new values are added into the array. However, "name_servers" gets the "stringified" value of the array...
I also tried removing the field first in case it made any difference to no avail.
I checked with "stdout{codec=>rubydebug}" and the value of "name_servers" is definitely an array.
This is the mapping for both fields:
"name_servers": {
"type": "string",
"index": "analyzed"
},
"past_name_servers": {
"type": "string",
"index": "analyzed"
}
If I were to use the following instead, it works:
ctx._source.name_servers = "%{name_servers}".split(",");
However, I believe I'm missing out on a way to take my formatted array and assign the value as such without having to go array=>string=>array each and every time.