# Ingest Node: Adding new Objects?

**URL:** <https://discuss.elastic.co/t/ingest-node-adding-new-objects/180189>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [May 8, 2019, 2:08pm UTC](https://discuss.elastic.co/t/ingest-node-adding-new-objects/180189 "2019-05-08T14:08:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterPain](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@PeterPain](https://discuss.elastic.co/u/PeterPain)\
**Post date:** [May 8, 2019, 2:08pm UTC](https://discuss.elastic.co/t/ingest-node-adding-new-objects/180189/1 "2019-05-08T14:08:14Z")

</div>

Hey there !  
Im pulling data from a device via http-module (metricbeat).  
Unfortunately the Data is put in mixed datatypes within one array (elasticsearch doesn't support these types of arrays)

_First Example_

{`"_P_SUM3": [260.4908,"W"]}`

_Second Example_

```
{ "_ULN": [[ 
224.2511,
225.7967,
226.3067],"V"]}

```

For the first example i was able to create a new field with the script processor.

```
{
  "testpipeline" : {
    "description" : "Data_Parsing",
    "processors" : [
      {
        "script" : {
          "lang" : "painless",
          "source" : """
          ctx.Psum = ctx.http.Janitza_Monti2._P_SUM3[0];
"""
        },
        "remove" : {
          "field" : [
            "http.Janitza_Monti2._P_SUM3",
          ]
        }
      }
    ]
  }
}

```

My Question for Example 2 is how do i access these kinds of arrays in the script processor.  
I tried using this term:  
`ctx.cosphi1 = ctx.http.Janitza_Monti2._COS_PHI[0][0];`

But that doesn't work.

Second Question: Is it possible to create a field of objects with the script processor ? Like this structure ?

{  
"new\_field": {  
"name": "my\_name",  
"value": "[value1, value2, value3]"  
}  
}

---

<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:** [May 9, 2019, 11:34am UTC](https://discuss.elastic.co/t/ingest-node-adding-new-objects/180189/2 "2019-05-09T11:34:03Z")

</div>

painless has this syntax for accessing arrays: i.e. `foo[0]` to access the first element.

So the second example would be something like `ctx._ULN[0][1]` to access the `225` value.

Regarding your second question: yes, you can create such a structure.

---

<div class="post-metadata">

**Author:** ![PeterPain](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@PeterPain](https://discuss.elastic.co/u/PeterPain)\
**Post date:** [May 9, 2019, 12:31pm UTC](https://discuss.elastic.co/t/ingest-node-adding-new-objects/180189/3 "2019-05-09T12:31:37Z")

</div>

Thanks for the answer,  
i was able to access the data in the array 😄 👍

---

<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:** [June 6, 2019, 12:31pm UTC](https://discuss.elastic.co/t/ingest-node-adding-new-objects/180189/4 "2019-06-06T12:31:46Z")

</div>

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