# Process array elements as objects

**URL:** <https://discuss.elastic.co/t/process-array-elements-as-objects/110682>\
**Category:** Logstash\
**Created:** [December 7, 2017, 1:55pm UTC](https://discuss.elastic.co/t/process-array-elements-as-objects/110682 "2017-12-07T13:55:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Boer](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Peter\_Boer](https://discuss.elastic.co/u/Peter_Boer)\
**Post date:** [December 7, 2017, 1:55pm UTC](https://discuss.elastic.co/t/process-array-elements-as-objects/110682/1 "2017-12-07T13:55:38Z")

</div>

I am trying to add json data to my elasticsearch with arrays in its field. My setup works, but I want the arrays to become separate fields. Is this possible in logstash or should i create a json parser to fix my problem?

```
{
	"name": "peter",
	"occupation": "salesman",
	"score": [{
			"result": true,
			"name": "reported"
		},
		{
			"result": false,
			"name": "processed"
		}
	],
	"level": 38,
	"categories": [{
			"category": "owner",
			"passed": false
		},
		{
			"category": "worker",
			"passed": true
		}
	]
}

```

My config file:

```
input { stdin {}
}

filter {
        json {
                source => "message"
                target => "message"
        }

}

output {
        elasticsearch {
                hosts => ["IP:9200"]
                        index => "worker"
                        document_id => "%{message}"
                        doc_as_upsert => true
                        action => "update"
                        retry_on_conflict => 10
        }
}
```

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 7, 2017, 2:22pm UTC](https://discuss.elastic.co/t/process-array-elements-as-objects/110682/2 "2017-12-07T14:22:37Z")

</div>

> I want the arrays to become separate fields

I don't understand what you mean by this. Please give an example of the JSON document you want to get.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [December 7, 2017, 2:24pm UTC](https://discuss.elastic.co/t/process-array-elements-as-objects/110682/3 "2017-12-07T14:24:19Z")

</div>

> [@Peter\_Boer](#):
>
> document\_id =\> "%{message}"

Why are you using the message field as ID?

---

<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:** [January 4, 2018, 2:24pm UTC](https://discuss.elastic.co/t/process-array-elements-as-objects/110682/4 "2018-01-04T14:24:25Z")

</div>

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