# Ingest node script processor issue

**URL:** https://discuss.elastic.co/t/ingest-node-script-processor-issue/106442
**Category:** Elasticsearch
**Created:** [November 5, 2017, 7:14pm UTC](https://discuss.elastic.co/t/ingest-node-script-processor-issue/106442 "2017-11-05T19:14:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ashish\_Barnwal](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@Ashish\_Barnwal](https://discuss.elastic.co/u/Ashish_Barnwal)
#### Post date: [November 5, 2017, 7:14pm UTC](https://discuss.elastic.co/t/ingest-node-script-processor-issue/106442/1 "2017-11-05T19:14:07Z")

</div>

Hi All,

I'm trying to create new fields and corresponding value based on the values present in two different arrays while parsing the data in ingest node pipeline. For e.g., Array1 = [num1,num2] and Array2 = [10,20]  
Expected output: num1 = 10, num2=20.

I'm trying to achieve this using script processor as shown below:

{"script": {  
"lang": "painless",  
"inline": "def source\_fields = ctx.Array1;def target\_fields = ctx.Array2 ;for(def i=0; i\<source\_fields.length; i++) {  
ctx.Array1[i]= target\_fields[i]; }"  
}}

This one just changes the content or Array1 to [10,20]. Can you please help.

Thanks,  
Ashish

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [November 6, 2017, 7:51am UTC](https://discuss.elastic.co/t/ingest-node-script-processor-issue/106442/2 "2017-11-06T07:51:21Z")

</div>

try sth like `ctx['array' + i] = target_fields[i]`

note however that this pretty dangerous as you can easily do a field explosion, so you should maybe cap this somewhere.

---

<div class="post-metadata">

### Author: ![Ashish\_Barnwal](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@Ashish\_Barnwal](https://discuss.elastic.co/u/Ashish_Barnwal)
#### Post date: [November 6, 2017, 8:24am UTC](https://discuss.elastic.co/t/ingest-node-script-processor-issue/106442/3 "2017-11-06T08:24:47Z")

</div>

> [@spinscale](#):
>
> maybe

Thanks Alexander for your reply. However this is not giving desired results. Its generating two new fields:

Array0: 10  
Array1: 20

Expected output is num1=10, num2=20.

---

<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: [December 4, 2017, 8:24am UTC](https://discuss.elastic.co/t/ingest-node-script-processor-issue/106442/4 "2017-12-04T08:24:48Z")

</div>

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