# Add array of object into an array through logstash

**URL:** <https://discuss.elastic.co/t/add-array-of-object-into-an-array-through-logstash/318335>\
**Category:** Logstash\
**Tags:** painless\
**Created:** [November 7, 2022, 1:45pm UTC](https://discuss.elastic.co/t/add-array-of-object-into-an-array-through-logstash/318335 "2022-11-07T13:45:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yashveer](https://avatars.discourse-cdn.com/v4/letter/y/74df32/32.png) [@yashveer](https://discuss.elastic.co/u/yashveer)\
**Post date:** [November 7, 2022, 1:45pm UTC](https://discuss.elastic.co/t/add-array-of-object-into-an-array-through-logstash/318335/1 "2022-11-07T13:45:57Z")

</div>

NEED TO DO THIS THOROUGH LOGSTASH ONLY  
'''  
index =\> "test-voq-local"

```
script_type => "inline"

document_id => "%{[i_odino]}"
scripted_upsert => true
action => "update"
script => "ctx._source.record.add(params.data); params : { data : {'name' : %{[name]}; 'ts' : %{[ts]}}}"
script_lang => "painless"

```

Wanted to add name and time stamp object to exisitng array record.  
so that output would be.

i\_odino:1 #already stored data  
state: DL # already stored data  
record: [ # data would be added in this array as an object  
{ name: "ABC", TS : " 2022-09-15T11:00:09.0000000"},  
{ name: "XYZ", TS: " 2021-10-15T11:00:09.0000000"}  
]

any one has any lead would be great.

---

<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 5, 2022, 1:46pm UTC](https://discuss.elastic.co/t/add-array-of-object-into-an-array-through-logstash/318335/2 "2022-12-05T13:46:07Z")

</div>

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